Android:LinearLayout旁边的表格布局

Android:LinearLayout旁边的表格布局,android,layout,android-linearlayout,tablelayout,Android,Layout,Android Linearlayout,Tablelayout,在Android中,我试图使用这个xml在LinearLayout旁边获得一个TableLayout。但我不能让它工作。TableLayout总是占据整个屏幕的宽度。如何使其与LinearLayout共享屏幕宽度 <LinearLayout android:layout_width="fill_parent" android:weightSum="1" android:layout_height="wrap_content" android:orientation="horizontal"

在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。我会将根元素设置为相对布局,然后声明线性布局应该位于表布局的右侧。

xml工作正常,可以生成所需的结果,并使用相对布局进行了完美的标记。我想问题可能出在模拟器上,因为我在真实设备上测试时,我的第一个xml也能工作。