2016-11-06 84 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