2016-11-06 79 views
0

我有下一个GridView布局,我从它们的适配器膨胀。我正在显示布局和标题,但我看不到图像。无论如何,我看到屏幕上的空白。任何想法?GridView项目布局不显示图像

<?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> 
+0

显示,请您适配器的一些代码。 – Kyrmyzyanik

+0

发布您的适配器代码。 –

回答

1

你已经添加的gradle 程序兼容性库

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

监守app:srcCompat属性实际上程序兼容性库中定义。

您可以使用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

+0

非常感谢!你能添加更多关于这方面的信息吗?这工作,但我喜欢知道为什么:S – Genaut