Android ListView对齐-如何对齐?
在一行中,我想将一些文本向左对齐,一些文本向右对齐。例如:Android ListView对齐-如何对齐?,android,android-layout,listview,Android,Android Layout,Listview,在一行中,我想将一些文本向左对齐,一些文本向右对齐。例如: |row1-leftmost row1-rightmost| |row2-leftmost row2-rightmost| |row3-leftmost row3-rightmost| 如何实现这一点?您可以使用重量和重力、重量力文本视图来获取可用的最大宽度,但您需要将宽度设置为0dp,重力只需将文本放置在可用空间中即可示例: <LinearLayout android:layout_
|row1-leftmost row1-rightmost|
|row2-leftmost row2-rightmost|
|row3-leftmost row3-rightmost|
如何实现这一点?您可以使用重量和重力、重量力文本视图来获取可用的最大宽度,但您需要将宽度设置为0dp,重力只需将文本放置在可用空间中即可示例:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="first text"/>
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="end"
android:text="second text"/>
</LinearLayout>