我在@drawable文件夹中使用复制粘贴添加了2个图像,但是我收到错误
Error:(25) No resource identifier found for attribute 'srcCompat' in package 'com.example.francydarkcool.maps'
我已经添加:
defaultConfig {
vectorDrawables.useSupportLibrary = true;
...
}
在build.gradle中
并且:
ImageView img1 = new ImageView(this);
img1.setImageResource(R.drawable.cascada3);
setContentView(img1);
ImageView img2 = new ImageView(this);
img2.setImageResource(R.drawable.cascada1);
setContentView(img2);
在我的.java文件中.
这是我的activity_cascada_urlatoarea.xml文件:
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#479fc7"
android:orientation="vertical"
android:weightSum="480">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="1">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:layout_weight="1"
android:orientation="vertical" >
android:layout_width="wrap_content"
android:layout_height="227dp"
app:srcCompat="@drawable/cascada3"
android:id="@+id/imageView5"
android:layout_weight="0.50"
/>
android:layout_width="match_parent"
android:layout_height="200dp"
app:srcCompat="@drawable/cascada1"
android:id="@+id/imageView7"
android:layout_weight="0.33"
/>
android:layout_width="match_parent"
android:layout_height="68dp"
android:orientation="horizontal"
android:weightSum="1">
android:text="Back"
android:layout_width="118dp"
android:layout_height="29dp"
android:id="@+id/button2"
android:background="@color/cast_mini_controller_main_background"
android:textSize="14sp"
android:textStyle="normal|bold"
android:textAlignment="center"
android:layout_marginTop="30dp"
android:onClick="backbttn"
android:layout_marginLeft="20dp"/>
android:text="Next"
android:layout_width="118dp"
android:layout_height="29dp"
android:id="@+id/button8"
android:background="@color/cast_mini_controller_main_background"
android:textAlignment="center"
android:textStyle="normal|bold"
android:layout_weight="0.16"
android:layout_marginTop="30dp"
android:layout_marginLeft="110dp"
android:onClick="nextbttn"/>
如果我试着改变
xmlns:app="http://schemas.android.com/apk/res-auto"
同
xmlns:app="http://schemas.android.com/apk/lib/com.app.chasebank"
我没有错误,但没有显示图像……
请帮忙.
解决方法:
确保在您的应用程序的build.gradle文件中依赖…您正在使用最新版本的支持库(任何版本23.3都可以).
compile 'com.android.support:appcompat-v7:24.1.1'
然后清理并重建项目.
标签:java,android,android-studio,imageview
来源: https://codeday.me/bug/20190527/1166134.html