То, что вы, возможно, хотите, это использовать TableLayout
вместо. GridView
аналогично ListView
, в котором есть предметы, но в этом случае вы хотите иметь только 4 предмета, а не неопределенное количество.
GridView
GridView - это группа ViewGroup, которая отображает элементы в двумерной сетке с возможностью прокрутки. Элементы сетки автоматически вставляются в макет с помощью ListAdapter.
TableLayout
TableLayout - это ViewGroup, которая отображает дочерние элементы View в строках и столбцах.
Вот фрагмент кода xml, который будет работать:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/MyGrid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:gravity="center"
android:padding="5dp"
android:stretchColumns="0,1" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
</TableLayout>