开发者

Android: TableLayout next to LinearLayout

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜