在TableLayout的Andr​​oid的EditText逃跑Andr、TableLayout、EditText、oid

2023-09-05 23:43:23 作者:纸醉金迷

我在tablelayout一个简单的标志,但里面的内容被拉伸太远的权利。一切似乎我为中心。或者,它似乎像的EditText正试图中心本身主父里面,而不是它的父tablelayout。知道为什么吗?

I have a simple sign in tablelayout, but the contents inside are stretching too far to the right. Everything appears to me to be centered. Or it seems like the EditText is trying to center itself inside the main parent and not IT'S parent tablelayout. Any idea why?

<?xml version="1.0" encoding="UTF-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bluebg"
android:id="@+id/loading_page_lin_layout"
>
 <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/roundtable"
        android:layout_gravity="center"
        android:gravity="center"
        android:layout_margin="10dip"
        android:padding="10dip"
        android:stretchColumns="*">
        <TableRow>
            <EditText  
            android:id="@+id/txtUserName"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#85AFBE"                              
            android:hint="Email"
            android:text=""
            android:gravity="left"

            />
         </TableRow>
        <TableRow>
            <EditText  
                android:id="@+id/txtPassword"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#85AFBE"                              
                android:text=""
                android:hint="Password"
                android:password="true"
                android:gravity="left"  
                android:layout_gravity="center"                     
                />
        </TableRow>
        <TableRow>
            <!--  <Button
            android:id="@+id/btnSignIn"
            android:text="Sign In" 
            android:layout_width="fill_parent"
            android:paddingTop="10dip"
            android:gravity="center"
            />-->
            <ImageButton 
             android:id="@+id/btnSignIn"
             android:src="@drawable/signbig"    
             android:scaleType="fitCenter"   
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"                
             android:adjustViewBounds="true"
             android:layout_marginLeft="3dip"
             android:background="@null"
             android:layout_marginRight="3dip"
             android:layout_gravity="center"
             />
        </TableRow>
        <TableRow>
            <Button
            android:id="@+id/btnSignUp"
            android:background="@null"
            android:text="Sign Up" 
            android:textStyle=""
            android:layout_width="wrap_content"
            android:paddingTop="10dip"
            android:textSize="20dip"
            android:gravity="center"
            android:onClick="SendToSignUp"
            />                          
        </TableRow> 
        <TableRow>
            <Button
               android:id="@+id/btnFillData"
               android:text="Fill Fake Data" 
               android:background="@null"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:paddingTop="10dip"
               android:gravity="center"
               android:onClick="FillFakeData"
               />
           </TableRow>
</TableLayout>
</LinearLayout>

推荐答案

您表的布局有它的宽度设置为WRAP_CONTENT和它的孩子们就在FILL_PARENT,他们没有一个人知道事情究竟:)设置你的表布局的宽度设置为FILL_PARENT,一切都应该制定出你的意思是它。

Your table layout has it's width set to "wrap_content" and it's children have it at "fill_parent", not one of them knows anything exactly :) Set your table layout's width to "fill_parent" and everything should lay out as you mean it to.

UPD 我只看到你的表一列。这意味着你可以安全地与垂直的LinearLayout代替它。

UPD I only see one column in your table. That means you can safely substitute it with vertical LinearLayout.