[英]How can I make this form on Android?
I have tried to make this small form in Android, but have not been able to make the space in the third and fourth rows. 我试图在Android中制作这种小表格,但是无法在第三行和第四行中留出空间。
尽管您可以使用RelativeLayout来实现此功能,但它是使用ConstraintLayout的理想选择,它可以让您指定元素之间的相对位置,以及在平板电脑上或在多窗口模式下调整窗口大小时,元素应如何自行扩展/重新定位。
Something like this : 像这样的东西:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Apellidos"/>
<EditText
android:id="@+id/editText"
android:layout_toRightOf="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hind="Apellidos"/>
<LinearLayout
android:layout_below="@+id/editText"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_weight="1"
android:layout_marginRight="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="Ciudad"/>
<EditText
android:layout_toRightOf="@+id/text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hind="Apellidos"/>
</RelativeLayout>
<RelativeLayout
android:layout_marginLeft="20dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="Ciudad"/>
<EditText
android:layout_toRightOf="@+id/text3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hind="Apellidos"/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
Edit : 编辑:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/name"
android:orientation="vertical"
android:gravity="right"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:id="@+id/text"
android:padding="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Apellidos"/>
<TextView
android:id="@+id/text1"
android:padding="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Apelli"/>
</LinearLayout>
<LinearLayout
android:id="@+id/value"
android:orientation="vertical"
android:layout_toRightOf="@+id/name"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/text"
android:hind="Apellidos" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_weight="2"
android:layout_toRightOf="@+id/text2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:hind="Apellidos"/>
<TextView
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:id="@+id/text2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Ciudad"/>
<EditText
android:layout_weight="2"
android:layout_toRightOf="@+id/text2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hind="xyz"/>
</LinearLayout>
</LinearLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.