Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
文本视图远离edittext android_Android_Xml - Fatal编程技术网

文本视图远离edittext android

文本视图远离edittext android,android,xml,Android,Xml,我不知道为什么Username:和Password:与edittext表单相差如此之远。有人能帮我修一下吗 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"

我不知道为什么Username:和Password:与edittext表单相差如此之远。有人能帮我修一下吗

      <RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  >

  <TableLayout
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  >

  <TableRow
  android:layout_gravity="center"
  android:gravity="center"
  android:layout_marginTop="10dp"
  >

   <TextView 
   android:text="Username : "
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:id="@+id/userset"
   style="@style/regFont"
   />

   <EditText
   android:id="@+id/versionuser"
   android:layout_height="wrap_content"
   android:layout_width="200dp"
   android:layout_toRightOf="@id/userset">
   <requestFocus>
   </requestFocus>
   </EditText>

   </TableRow>

   <TableRow
   android:layout_gravity="center"
   android:gravity="center"
   android:layout_marginTop="5dp"
   >

   <TextView 
   android:text="Password : "
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:id="@+id/passset"
   style="@style/regFont"
   />

   <EditText
   android:id="@+id/versionpass"
   android:layout_height="wrap_content"
   android:layout_width="200dp"
   android:layout_marginTop="5dp"
   android:layout_toRightOf="@id/passset"
   android:inputType="textPassword">
   </EditText>
   </TableRow>

   <TableRow
   android:layout_gravity="center"
   android:gravity="center"
   android:layout_marginTop="5dp"
   >

   <CheckBox
   android:text="Automatic Login"
   android:id="@+id/cbauto"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content">
   </CheckBox>

   </TableRow>

   </TableLayout>

   </RelativeLayout>

这是因为您的复选框使用了表格布局的第一行。因此,TextView将使用与复选框相同的大小

您应该尝试为复选框项创建单独的TableLayout,这样它就不会占用前面的TableRows的宽度,然后将两个TableLayout放入一个封闭的LinearLayout中,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" android:orientation="vertical">

  <TableLayout
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  >

  <TableRow
  android:layout_width="fill_parent"
   android:layout_height="wrap_content"
  android:layout_gravity="left"
  android:gravity="left"
  android:layout_marginTop="10dp"
  >

   <TextView 
   android:text="Username : "
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:id="@+id/userset"
   />

   <EditText
   android:id="@+id/versionuser"
   android:layout_height="wrap_content"
   android:layout_width="200dp"
   android:layout_toRightOf="@id/userset">
   <requestFocus>
   </requestFocus>
   </EditText>

   </TableRow>

   <TableRow
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:layout_gravity="left"
   android:gravity="left"
   android:layout_marginTop="5dp"
   >

   <TextView 
   android:text="Password : "
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:id="@+id/passset"
   />

   <EditText
   android:id="@+id/versionpass"
   android:layout_height="wrap_content"
   android:layout_width="200dp"
   android:layout_marginTop="5dp"
   android:layout_toRightOf="@id/passset"
   android:inputType="textPassword">
   </EditText>
   </TableRow>

   </TableLayout>
  <TableLayout android:layout_marginTop="5dp" android:gravity="left" android:layout_height="wrap_content" android:layout_width="fill_parent">
      <CheckBox android:layout_width="wrap_content" android:text="Automatic Login" android:layout_height="wrap_content" android:id="@+id/cbauto"></CheckBox>
  </TableLayout>

</LinearLayout>

这是因为您的复选框使用了表格布局的第一行。因此,TextView将使用与复选框相同的大小

您应该尝试为复选框项创建单独的TableLayout,这样它就不会占用前面的TableRows的宽度,然后将两个TableLayout放入一个封闭的LinearLayout中,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" android:orientation="vertical">

  <TableLayout
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  >

  <TableRow
  android:layout_width="fill_parent"
   android:layout_height="wrap_content"
  android:layout_gravity="left"
  android:gravity="left"
  android:layout_marginTop="10dp"
  >

   <TextView 
   android:text="Username : "
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:id="@+id/userset"
   />

   <EditText
   android:id="@+id/versionuser"
   android:layout_height="wrap_content"
   android:layout_width="200dp"
   android:layout_toRightOf="@id/userset">
   <requestFocus>
   </requestFocus>
   </EditText>

   </TableRow>

   <TableRow
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:layout_gravity="left"
   android:gravity="left"
   android:layout_marginTop="5dp"
   >

   <TextView 
   android:text="Password : "
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:id="@+id/passset"
   />

   <EditText
   android:id="@+id/versionpass"
   android:layout_height="wrap_content"
   android:layout_width="200dp"
   android:layout_marginTop="5dp"
   android:layout_toRightOf="@id/passset"
   android:inputType="textPassword">
   </EditText>
   </TableRow>

   </TableLayout>
  <TableLayout android:layout_marginTop="5dp" android:gravity="left" android:layout_height="wrap_content" android:layout_width="fill_parent">
      <CheckBox android:layout_width="wrap_content" android:text="Automatic Login" android:layout_height="wrap_content" android:id="@+id/cbauto"></CheckBox>
  </TableLayout>

</LinearLayout>