2016-08-01 54 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