ответ Адама не сработал для меня.Это то, что я нашел, чтобы работать отлично:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView android:id="@+id/top_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<Button android:id="@+id/bottom_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
<LinearLayout
android:id="@+id/container_layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/bottom_button"
android:layout_below="@id/top_image"
android:gravity="center" >
<GridView android:id="@+id/grid"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
</RelativeLayout>
Я использовал это с другими LinearLayouts
вместо GridView
, с android:gravity="center"
, установленным на самой внутренней компоновке, чтобы сделать всетекстовых изображений и изображений по центру как по горизонтали, так и по вертикали.