在横向模式下无法在屏幕底部看到ListView

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

LinearLayout的顶部是ImageView,TextView,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" />
suijianzhi 回答:在横向模式下无法在屏幕底部看到ListView

通过以下方法实现了此目的: https://stackoverflow.com/a/36030926/5696328

此: https://stackoverflow.com/a/27898262/5696328

这: https://stackoverflow.com/a/26998840/5696328

本文链接:https://www.f2er.com/2931104.html

大家都在问