【发布时间】:2016-01-27 13:40:59
【问题描述】:
我正在尝试并排放置两个 TextView,我希望一个触摸屏幕右侧,另一个触摸左侧。我不想使用数字定义宽度,因为不同尺寸的屏幕会表现不同。所以我正在尝试使用 layout_gravity,但由于某种原因它不起作用。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16dp"
android:layout_gravity="left"
android:text="rrr"
android:textColor="@color/secondTextColor"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textSize="16dp"
android:text="sss"
android:textColor="@color/secondTextColor" />
</LinearLayout>
谁能告诉我为什么?谢谢!
【问题讨论】:
-
这两个文本视图之间是否应该相互接触?还是 1 只接触左边,另一个右边,它们之间不接触?如果他们介于两者之间,那么
weight就足够了,你不需要weightSum