Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/180.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android TableLayout显示在另一个TableLayout的顶部_Android_Android Layout - Fatal编程技术网

Android TableLayout显示在另一个TableLayout的顶部

Android TableLayout显示在另一个TableLayout的顶部,android,android-layout,Android,Android Layout,我有以下定义: <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/leftContainer" android:layout_weight="0.8"> <TableLayout android:id="@+id/drinksTable" andr

我有以下定义:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/leftContainer"
    android:layout_weight="0.8">
    <TableLayout
        android:id="@+id/drinksTable"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:shrinkColumns="*"
        android:stretchColumns="*"
        android:padding="0dp" />
    <TableLayout
        android:id="@+id/itemsTable"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:shrinkColumns="*"
        android:stretchColumns="*"
        android:padding="0dp"
        android:layout_alignParentBottom="true" />
</RelativeLayout>

这两种表格布局都是以编程方式构建的

我希望第二个表直接显示在第一个表的下面,但是我能做的最好的事情是让它位于我不喜欢的布局底部(使用alignParentBottom)


如何让
itemsTable
直接显示在
drinksTable
下方?

只需将布局转换为
线性布局
,确保添加
android:orientation=“vertical”
;这将使每个元素垂直堆叠

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/leftContainer"
    android:layout_weight="0.8"
    android:orientation="vertical">
    <TableLayout
        android:id="@+id/drinksTable"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:shrinkColumns="*"
        android:stretchColumns="*"
        android:padding="0dp" />
    <TableLayout
        android:id="@+id/itemsTable"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:shrinkColumns="*"
        android:stretchColumns="*"
        android:padding="0dp"
        android:layout_alignParentBottom="true" />
</LinearLayout>


但是,请注意,如果元素数量太多,它们将从屏幕底部流出。(您可能希望将此
线性布局
包装在
滚动视图中

我将使用垂直
线性布局
。你到底想怎么设置?一半一半?一个比另一个大?滚动?而
RelativeLayout
的父级是什么?嘿,Eric,父级是线性布局。屏幕垂直分为两半,此相对布局填充屏幕左侧50%的区域。我希望第二个表显示在第一个表下面,因为第一个表中的项目数是可变的。谢谢Eric!谢谢你的帮助。