Высота Gridview уменьшена

Я пытаюсь отобразить 8 элементов внутри представления сетки. К сожалению, высота представления сетки всегда слишком мала, поэтому отображается только первая строка и небольшая часть второй .

Настройка android: layout_height = "300dp" заставляет его работать. Wrap_ content и fill_parent по-видимому, нет.

Мое представление сетки:

<GridView
    android:id="@+id/myId"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:horizontalSpacing="2dp"
    android:isScrollContainer="false"
    android:numColumns="4"
    android:stretchMode="columnWidth"
    android:verticalSpacing="20dp" />

] Ресурс Мои элементы:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:minHeight="?android:attr/listPreferredItemHeight" >

    <ImageView
        android:id="@+id/appItemIcon"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@android:drawable/ic_dialog_info"
        android:scaleType="center" />      

    <TextView
        android:id="@+id/appItemText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="My long application name"
        android:gravity="center_horizontal"
        android:textAppearance="?android:attr/textAppearanceSmall" />

</LinearLayout>

Проблема, похоже, не связана с нехваткой вертикального пространства.

Что я могу сделать?

120
задан Wryday 18 December 2014 в 20:50
поделиться