Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/420.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
Android ListView对齐-如何对齐?_Android_Android Layout_Listview - Fatal编程技术网

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>