I have a LinearLayout android:id="@+id/content_frame"
nested inside a DrawerLayout android:id="@+id/drawer_layout"
.
At the top of the LinearLayout are ImageViews, TextViews, Buttons, Switches etc. These are nested in a selection of horizontal and vertical LinearLayouts. All good so far.
At the bottom of the LinearLayout is a ListView which is also nested in its own a LinearLayout. So my Layout looks like the below. (Gravity, Padding etc. parameters removed below to save space).
All is good in the world in Portrait Orientation, but once I change to Landscape the screen height is too small on many devices to see my ListView in the bottom half of the screen.
I have tried wrapping it all in a ScrollView, but then my ListView wont auto size to fill_parent
and remains one item tall, and with ScrollView in Landscape Orientation it wont let me scroll the ListView at all.
Could someone please recommend a way to allow me to see my ListView at the bottom of the screen and Scroll it in both Portrait and Landscape modes?
Thank you in advance!!
<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" />