我知道您可以对线性布局使用权重参数,以使两个字段很好地对齐。我想做的是确保屏幕的左半部分被一个文本字段使用,另一半屏幕被其他文本字段使用(我说的是宽度)。 怎么做?
最佳答案
在中心使用一个没有高度或宽度的“隐藏 View ”,并将 TextView 放在两侧。使用父对齐设置左右。
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<View android:id="@+id/dummy"
android:layout_height="0dp"
android:layout_width="0dp"
android:layout_centerInParent="true"/>
<TextView
android:layout_alignRight="@id/dummy"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"/>
<TextView
android:layout_alignLeft="@id/dummy"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"/>
</RelativeLayout>
关于android - 如何在相对布局(android)中并排获得两个字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21368884/