如果您的表格只有两列,则可能更容易使用线性布局,并为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
总和。