开发者

Android: TableLayout next to LinearLayout

开发者 https://www.devze.com 2023-03-06 20:36 出处:网络
In Android I\'m trying to use this xml to get a TableLayout next to a LinearLayout. But I can\'t get it working. The TableLayout always takes up the full width of the screen. How can I get it to share

In Android I'm trying to use this xml to get a TableLayout next to a LinearLayout. But I can't get it working. The TableLayout always takes up the full width of the screen. How can I get it to share the screen width with the 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>


Like stated above, don't put the table width as 0dp. I would make the root element a Relative layout then state that the linear layout should be to the right of the table layout.


this says that your layout width of the linear layout is 0dp. make it wrap content and have the table layout with weight: 1 > linear: 0 and table layout set to fill parent.

0

精彩评论

暂无评论...
验证码 换一张
取 消