¿Cómo dividir la pantalla en tres partes verticalmente?

Tengo una pantalla con ScrollView y tres LinearLayouts diferentes.

Un LinearLayout contiene un Spinner y el segundo contiene ListView y el tercero contiene dos Buttons (horizontal).

Quiero mostrar una pantalla que contenga 3 LinearLayouts siempre mostrados en la parte inferior de la pantalla y 1 LinearLayout siempre mostrado en la parte superior. En la parte media, quiero mostrar el contenido de ListView . Así que en toda la pantalla no hay espacio en blanco presente.

Quiero crear una pantalla para varios dispositivos que tiene diferentes tamaños.

  <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/backrepeat" android:orientation="vertical" > <include android:id="@+id/include1" android:layout_width="fill_parent" android:layout_height="wrap_content" layout="@layout/actionbar" > </include> <ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" android:scrollbars="horizontal" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:padding="10dp" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight=".2" android:background="@drawable/rounded_border" android:orientation="vertical" android:padding="15dp" > <TextView android:id="@+id/tvDiaryData" style="@style/greenstyle" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/heading" android:gravity="center_horizontal" android:text="@string/tvDiaryData" > </TextView> <TextView android:layout_width="fill_parent" android:layout_height="10dp" android:gravity="center_horizontal" > </TextView> <Spinner android:id="@+id/spDiaryAllBooking" android:layout_width="fill_parent" android:layout_height="wrap_content" android:prompt="@string/select_diaryallbooking" /> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.6" android:background="@drawable/layerlist" android:orientation="vertical" android:paddingBottom="5dp" android:paddingLeft="15dp" android:paddingRight="15dp" android:paddingTop="5dp" > <ListView android:id="@+id/lvDiaryBooking" android:layout_width="fill_parent" android:layout_height="fill_parent" android:divider="#636466" android:layout_weight="1" android:dividerHeight="1dip" android:scrollbarStyle="outsideOverlay" android:scrollbarThumbVertical="@drawable/scrollbar_vertical_thumb" /> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight=".2" android:background="@drawable/rounded_border" android:orientation="horizontal" android:padding="10dp" > <Button android:id="@+id/btnDiaryBook" style="@style/greenButton" android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="fill_parent" android:onClick="btnDiaryBook_Click" android:text="@string/btnBook" > </Button> <Button android:id="@+id/btnDiaryBalance" style="@style/greenButton" android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginLeft="10dp" android:onClick="btnDiaryBalance_Click" android:text="@string/btnDiaryBalance" > </Button> </LinearLayout> </LinearLayout> </ScrollView> </LinearLayout> 

Disposición de la pantalla con lo que deseo:

Introduzca aquí la descripción de la imagen

Disposición actual: da espacio en blanco debajo de la pantalla en la tableta

Esta es una solución muy sencilla. Debe poder utilizar esto en su diseño actual.

Simplemente LinearLayouts los LinearLayouts con el contenido deseado.

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/ll1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" > </LinearLayout> <LinearLayout android:id="@+id/ll2" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" > </LinearLayout> <LinearLayout android:id="@+id/ll3" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" > </LinearLayout> </LinearLayout> 

Captura de pantalla del código publicado anteriormente con los colores que muestran las diferentes áreas de diseño.

Introduzca aquí la descripción de la imagen

  • Android cómo enfocar ActionBar searchView
  • AppWidgetProvider: onAppWidgetOptionsChanged no se llama en la ubicación del widget
  • Ocultar widget de la aplicación dependiendo del nivel de la API
  • Tamaño de la tostada en Galaxy Nexus
  • Obtenga la intención de onCreate en Android
  • Obtener minWidth (appwidget-provider) en todos los dispositivos, teléfonos y tablets
  • Obtención de tamaño de vista de imagen para creación de mapa de bits
  • ¿Cómo puedo crear un AttributeSet de un style.xml?
  • Cómo hacer que los GIF animados funcionen desde Android WebView
  • Cómo hacer una barra de progreso mostrar en la parte superior de un botón en android
  • Comprensión y uso de un contexto
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.