如何在线性布局的左侧和右侧对齐文本视图

时间:2015-06-20 05:59:20

标签: android layout android-linearlayout

根据以下代码

<LinearLayout android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:gravity="center_vertical|center_horizontal"
                  android:layout_marginTop="15dip">
        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="نوع"
                android:gravity="left"
                android:layout_weight="1"
                android:id="@+id/txt_type" />
        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="تاریخ: ۱۳۹۲/۰۳/۲۸"
                android:layout_weight="1"
                android:gravity="right"
                android:id="@+id/txt_date" />

    </LinearLayout>

TextViews没有很好地对齐,两者都没有完全一致。

就像下面的图片中所显示的那样。

enter image description here

1 个答案:

答案 0 :(得分:1)

请检查父版面并尝试将方向设置为水平。我尝试了不同的案例,但发现它在所有情况下都有效......

enter image description here

相关问题