在横向模式下看不到屏幕底部的ListView

问题描述 投票:0回答:1

我在DrawerLayout android:id="@+id/content_frame"中嵌套了LinearLayout android:id="@+id/drawer_layout"

LinearLayout的顶部是ImageViews,TextViews,Button,Switch等。它们嵌套在水平和垂直LinearLayouts中。到目前为止一切都很好。

LinearLayout的底部是一个ListView,它也嵌套在其自己的LinearLayout中。所以我的布局如下图所示。 (为了节省空间,下面删除了重力,填充等参数。)>

在纵向方向上,世界上一切都很好,但是当我更改为横向时,在许多设备上,屏幕高度都太小,无法在屏幕的下半部看到我的ListView。

[我曾尝试将它们全部包装在ScrollView中,但是我的ListView不会自动调整大小为fill_parent,并且仍然是一个项目,并且在Horizo​​nView方向使用ScrollView时,它根本不会让我滚动ListView。

有人可以推荐一种方法,让我在屏幕底部看到我的ListView并在纵向和横向模式下将其滚动吗?

谢谢你!!

<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/content_frame"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <LinearLayout
                    android:layout_width="32dp"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                    <ImageView />

                    <ImageView />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                    <ImageView />

                </LinearLayout>

            </LinearLayout>

            <EditText />

            <Spinner />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <Button />

            <Button />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <ProgressBar />

        </LinearLayout>


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <Button />

            <Switch />

        </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <ListView
                    android:id="@+id/myTeamsListView"
                    android:layout_width="match_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:background="@drawable/spinner"
                    android:alwaysDrawnWithCache="true"
                    android:contentDescription="@string/myTeamsListViewcontent"
                    android:isScrollContainer="false"
                    android:scrollbars="none"
                    android:scrollingCache="false"
                    android:smoothScrollbar="false"></ListView>

            </LinearLayout>
        </LinearLayout>

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        android:onClick="onSwitchChange"
        app:headerLayout= "@layout/nav_header_main"
        app:menu="@xml/drawer_view" />

我有一个嵌套在DrawerLayout android:id =“ @ + id / drawer_layout”内的LinearLayout android:id =“ @ + id / content_frame”。 LinearLayout的顶部是ImageViews,TextViews,按钮,开关等。...

listview android-listview android-xml screen-orientation
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.