具有相同列的两个TableLayout
问题描述:
我的TableLayouts中的列宽有问题。这是情况,我有多个TableLayouts需要对齐在一起,问题是他们在不同的XML文件(多次膨胀同一个),每个人都有一个TableLayout。具有相同列的两个TableLayout
这是XML
这是我怎么也想拥有它的图像。
我希望有人能帮助我。重要的是要知道,每行(TableLayout)都在它自己的XML中,并且我无法将TableLayout放置在这些XML之外。
答
如果您的表格只有两列,则可能更容易使用线性布局,并为LinearLayout的每个成员指定layout_weight
。这里有一个例子:
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="2">
<TextView android:id="@+id/txt1"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="Buy"/>
<TextView android:id="@+id/txt2"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="Share"/>
</LinearLayout>
你只需要确保该layout_weight
S上的各个观点款项高达父ViewGroup中的weightSum
总和。