0

我有一个包含 4 个 TextViews 的水平 LinearLayout。有时其中一个文本视图中的文本很长,并且最后一个文本视图不适合布局。
当然,我可以设置一个文本视图,但这不是最佳选择,因为文本是从不同的地方设置的并且具有不同的样式。
知道如何解决这个问题吗?
非常感谢。

4

1 回答 1

0

您可以使用权重在 LinearLayout 内分配视图,每个视图占 25%。

例如(未经测试,可能包含拼写错误):

<LinearLayout android:weightSum="100" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal">
<TextView android:layout_weight="25" android:layout_width="0dp" android:layout_height="wrap_content"></TextView>
<TextView android:layout_weight="25" android:layout_width="0dp" android:layout_height="wrap_content"></TextView>
<TextView android:layout_weight="25" android:layout_width="0dp" android:layout_height="wrap_content"></TextView>
<TextView android:layout_weight="25" android:layout_width="0dp" android:layout_height="wrap_content"></TextView>
</LinearLayout>
于 2012-09-23T09:43:17.653 回答