【发布时间】:2020-01-22 20:56:29
【问题描述】:
我需要this, where two columns have the same width (0 and 2) and another one stretches to fill the remaining space (col 1) 之类的东西。但是,两个相等的列的内容经常变化,所以有时第一列会比另一列大,反之亦然。我的第一个想法是使用 TableLayout 和 android:layout_weight,但这并没有多大帮助,因为我将 android:layout_weight="1" 和 android:layout_weight="2" 设置为中间的。
<TableRow
android:id="@+id/firstRow"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/0"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="0" />
<TextView
android:id="@+id/1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="2"
android:gravity="center"
android:text="1" />
<TextView
android:id="@+id/2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="2" />
</TableRow>
有没有办法只使用布局或以编程方式做到这一点?
【问题讨论】:
标签: android android-constraintlayout tablelayout android-tablelayout