2016-08-01 57 views
1

我正在開發一個Android應用程序,我很難在此處顯示示例圖像。Android ImageView始終爲空

XML:

<RelativeLayout 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:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.xwaybill.xdriver2.HelpActivity" 
android:background="#EAEAEA"> 

<ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    app:srcCompat="@drawable/footerlogo" 
    android:layout_alignParentTop="true" 
    android:id="@+id/imageView4" 
    android:adjustViewBounds="true" 
    android:elevation="21dp" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentEnd="true" /> 

See image for result

我在該決議中的所有文件夾的分辨率得到了圖像。這不是我的第一個應用程序,這是一箇舊的更新。因爲,我從Android 3遷移到6,我開始有這個麻煩之王。我也想提一下,我在另一個活動上有相同的確切圖像,並且它正確顯示。

謝謝。

回答

0

首先,在的build.gradle:

defaultConfig { 
    vectorDrawables.useSupportLibrary = true 
} 

二:

<ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    app:srcCompat="@drawable/XXXX" 
    tools:ignore="MissingPrefix" /> 

最後:

xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 

這篇文章可能有助於您:Can't use srcCompat for ImageViews in android

+0

我已經做了這是第一個交流基於那篇文章。這不是在這裏工作。謝謝。 – Daniel