在横向模式下看不到屏幕底部的列表视图



我有一个嵌套在抽屉布局android:id="@+id/drawer_layout"中的线性布局android:id="@+id/content_frame"

线性布局的顶部是ImageViews,TextViews,Buttons,Switch等。它们嵌套在一系列水平和垂直线性布局中。到目前为止一切都很好。

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

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

我尝试将其全部包装在滚动视图中,但是我的ListView不会自动调整大小为fill_parent并保持一个项目高,并且横向滚动视图根本不允许我滚动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" />

通过以下组合实现了这一点: https://stackoverflow.com/a/36030926/5696328

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

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

最新更新