android:src="@mipmap/img1" 大家好,在android里面imageView里面引入一个自己的图片,但是报错说: Rendering Problems Couldn't resolve resource @mipmap/img1 Failed to convert @mipmap/img1 into a drawable
Apps should use the mipmap/ resource folders for launcher icons. The mipmap/ folders replace the drawable/ folders for launcher icons. 引用自Android/Developer: Managing Launcher Icons as mipmap Resources 参考这个问题:mipmap vs drawable folders
如果按上述规则存储并引用图片,仍然碰到 failed to convert @drawable/picture into a drawable,尝试重启studio,参考这里
印象中Android对
res
路径下的文件夹和文件名称都是有特定要求的(暂时还没有找到出处,应该没有记错吧),你自己随便命名的文件夹对Android来说没有意义。针对图片来讲,drawable- hdpi、drawable-mdpi和drawable-xhdpi,这些目录都是有特别意义的。使用
@drawable/***
引用图片时,系统会根据屏幕像素密度从其中的某个文件夹中取出对应的图片。Update
在
mipmap-[density]
路径中放app icon图片,仍然在drawable-[density]
中放其它图片。因此,在Manifest中引用app icon时
android:icon="@mipmap/ic_launcher"
,在其它需要引用图片的地方仍然用@drawable/img1
.如果按上述规则存储并引用图片,仍然碰到
failed to convert @drawable/picture into a drawable
,尝试重启studio,参考这里