Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.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 让TableView和ListView占据整个屏幕宽度_Android_Listview_Android Layout_Tableview - Fatal编程技术网

Android 让TableView和ListView占据整个屏幕宽度

Android 让TableView和ListView占据整个屏幕宽度,android,listview,android-layout,tableview,Android,Listview,Android Layout,Tableview,我为Android上的布局提供了以下XML <?xml version="1.0" encoding="utf-8" ?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <!-- Select bu

我为Android上的布局提供了以下XML

<?xml version="1.0" encoding="utf-8" ?> 

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <!--  Select building row  -->
    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <TextView
            style="@style/Default"
            android:layout_width="200px"
            android:text="Gebouw:"/>

        <Spinner
            android:id="@+id/buildingSpinner"
            style="@style/Default"
            android:layout_width="300px"/>

    </TableRow>
    <!--  Select section row -->
    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <TextView
            style="@style/Default"
            android:layout_width="200px"
            android:text="Verdieping:"/>

        <Spinner
            android:id="@+id/SectionSpinner"
            style="@style/Default"
            android:layout_width="300px"/>

    </TableRow>
    <!--  Select room row -->
    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="300px"
            android:layout_margin="4px"
            android:layout_span="2"
            android:background="#BBBBBB">

                <ListView
                    android:id="@+id/roomsList"
                    style="@style/Default"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_margin="2px"
                    android:background="#EEEEEE"/>

                </LinearLayout>

    </TableRow>
    <!--  Buttons row -->
    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <TextView
            android:id="@+id/selectedRoomText"
            style="@style/Default"
            android:layout_width="fill_parent"
            android:text=""/>

        <Button
            android:id="@+id/btnCreateChecklistForRoom"
            style="@style/Default"
            android:text="OK"/>

    </TableRow>

</TableLayout>

我试图让TableView和ListView占据整个屏幕的宽度,但我似乎无法让它工作

也就是说,我还希望ListView在渲染其他元素后占据所有剩余的垂直空间


有什么建议吗?

将包含
列表视图的
表格行更改为以下内容:

<TableRow
        android:layout_width="fill_parent"
        android:layout_height="0dp" android:layout_weight="1">
- 

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_margin="4px"
            android:layout_span="2"
            android:background="#BBBBBB" android:layout_weight="1">

            <ListView
                android:id="@+id/roomsList"
                style="@style/Default"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_margin="2px"
                android:background="#EEEEEE"/>
        </LinearLayout>
    </TableRow>

- 

我不明白为什么你需要里面的
LinearLayout
。当属性移动到其父级或其子级时,可以删除它

将包含
列表视图的
表格行
更改为以下内容:

<TableRow
        android:layout_width="fill_parent"
        android:layout_height="0dp" android:layout_weight="1">
- 

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_margin="4px"
            android:layout_span="2"
            android:background="#BBBBBB" android:layout_weight="1">

            <ListView
                android:id="@+id/roomsList"
                style="@style/Default"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_margin="2px"
                android:background="#EEEEEE"/>
        </LinearLayout>
    </TableRow>

- 

我不明白为什么你需要里面的
LinearLayout
。可以将属性移动到其父级或其子级来删除它

是否格式化xml?它几乎不可读。介意格式化您的xml吗?这几乎是不可读的。我在里面添加了linearlayout来为listview创建边框,无法找到任何其他方法(ps,我来自XAML背景),因此您给出的示例确实使linearlayout使用了所有剩余的高度,但listview在其中收缩和增长。现在使用了更多的水平空间,但右侧仍有大量未使用的空间更新ListView的布局高度以填充父级解决了垂直问题我在内部添加了linearlayout以创建ListView的边框,无法找到其他方法(ps,我来自XAML背景),因此您给出的示例,确实会使LinearLayout耗尽所有剩余高度,但ListView会在其中收缩和增长。现在使用了更多的水平空间,但右侧仍然有大量未使用的空间,更新ListView的布局高度以填充父视图解决了垂直问题