GridView 项目布局不显示图像

GridView item layout not show image

我有下一个 GridView 布局,我正在从他们的适配器中扩充。我正在显示布局和标题,但看不到图像。无论如何,我在屏幕上看到了空白 space。有什么想法吗?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="200dp">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="150dp"
        app:srcCompat="@drawable/ic_icon_normal"
        android:id="@+id/imageView" />

    <TextView
        android:text="Title of the Item"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:id="@+id/titleButton"
        tools:text="Title of the Item"
        android:textAlignment="center"
        android:gravity="center_vertical" />

</LinearLayout>

您是否在 gradle 中添加了 AppCompat 库:

compile 'com.android.support:appcompat-v7:25.0.0'

因为 app:srcCompat 属性实际上是在 AppCompat 库.

中定义的

您可以使用 tools:ignore="MissingPrefix" 来避免暂时看到错误。

<android.support.v7.widget.AppCompatImageView
    android:id="@+id/imageView"
    android:layout_width="match_parent"
    android:layout_height="150dp"
    app:srcCompat="@drawable/ic_icon_normal"
    tools:ignore="MissingPrefix"/>

尝试使用AppCompatImageView