简体   繁体   English

Android Studio无法在可绘制对象中识别9patch图像

[英]Android Studio doesn't recognize 9patch images in drawables

I have a nine patch image and gave it a name like this: 我有一个九个补丁映像,并给它起了这样的名称:

img.9.png img.9.png

When I import it into drawable-hdpi or drawable-xhdpi folders and so on android studio is unable to recognize image and gives me an error : 当我将其导入drawable-hdpidrawable-xhdpi文件夹等时,android studio无法识别图像并给我一个错误:

Couldn't resolve resource @mipmap/img.9 无法解析资源@ mipmap / img.9
Failed to convert @mipmap/img.9 into a drawable 无法将@ mipmap / img.9转换为可绘制对象

Error:(69, 29) No resource found that matches the given name (at 'background' with value '@drawable/img'). 错误:(69,29)找不到与给定名称匹配的资源(在“背景”处,值为“ @ drawable / img”)。

Also when I import this 9patch image into drawable folder android studio displays it correctly but when I build and run application give an error: 另外,当我将此9patch图像导入可绘制文件夹时,android studio会正确显示它,但是在我构建并运行应用程序时出现错误:

Error:(69, 29) No resource found that matches the given name (at 'background' with value '@mipmap/img.9'). 错误:(69,29)找不到与给定名称匹配的资源(在“背景”处,值为“ @ mipmap / img.9”)。

The extension must be .9.png but you don't have to include .9 in your reference! 扩展名必须为.9.png,但您不必在参考中包括.9
So, it's not @mipmap/img.9 , but @mipmap/img 因此,它不是@mipmap/img.9 ,而是@mipmap/img

Moreover, mipmap shoul only be used for the launcher icon, not for the graphic resources. 而且, mipmap仅用于启动器图标,而不用于图形资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM