![](/img/trans.png)
[英]Android: how to split a screen for a TableLayout next to a LinearLayout?
[英]Android: TableLayout next to LinearLayout
在Android中,我嘗試使用此xml在LinearLayout旁邊獲取TableLayout。 但是我無法正常工作。 TableLayout始終占據屏幕的整個寬度。 如何獲取與LinearLayout共享的屏幕寬度?
<LinearLayout android:layout_width="fill_parent" android:weightSum="1" android:layout_height="wrap_content" android:orientation="horizontal">
<TableLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.5">
<TableRow>
<TextView android:text="Name1:" />
<TextView android:text="Value1" />
</TableRow>
<TableRow>
<TextView android:text="Name2:" />
<TextView android:text="Value2" />
</TableRow>
</TableLayout>
<LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.5"></LinearLayout>
</LinearLayout>
這表示線性布局的布局寬度為0dp。 使它包裝內容,並使表格布局的權重為:1>線性:0,並將表格布局設置為填充父級。
如上所述,請勿將表格寬度設為0dp。 我將使根元素成為相對布局,然后聲明線性布局應位於表布局的右側。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.