[英]Android error: AAPT: error: resource drawable/ic_bot (aka com.example.chatbot:drawable/ic_bot) not found
Getting the error in Build Output when I'm trying to run the app: ERROR:C:\Users\xxxxxxxx\AndroidStudioProjects\Chatbot\app\src\main\res\layout\bot_msg.xml:18: AAPT: error: resource drawable/ic_bot (aka com.example.chatbot:drawable/ic_bot) not found.当我尝试运行应用程序时在 Build Output 中出现错误:ERROR:C:\Users\xxxxxxxx\AndroidStudioProjects\Chatbot\app\src\main\res\layout\bot_msg.xml:18: AAPT: error: resource未找到 drawable/ic_bot(又名 com.example.chatbot:drawable/ic_bot)。
Here's the code in bot_msg.xml:这是 bot_msg.xml 中的代码:
<!--below widget is for image of bot-->
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="10dp"
android:src="@drawable/ic_bot" />
First time posting.第一次发帖。 Am a beginner.
我是初学者。
Make sure you have an image named ic_bot
in your project directory C:\.....\AndroidStudioProjects\Chatbot\app\src\main\res\drawable\
确保在项目目录
C:\.....\AndroidStudioProjects\Chatbot\app\src\main\res\drawable\
中有一个名为ic_bot
的图像
Android creates a Drawable resource for any of .png, .jpg, or.gif
files when you save them in the res/drawable/ directory. Android 为任何
.png, .jpg, or.gif
文件创建一个 Drawable 资源,当您将它们保存在 res/drawable/ 目录中时。
In your case:在你的情况下:
..\AndroidStudioProjects\Chatbot\app\src\main\res\drawable\
The filename is used as the resource ID.文件名用作资源 ID。 compiled resource datatype will be Resource pointer to a BitmapDrawable.
编译后的资源数据类型将是指向 BitmapDrawable 的资源指针。 and resource reference will be:
资源参考将是:
In Java: R.drawable.filename
在 Java:
R.drawable.filename
In XML: @[package:]drawable/filename
在 XML 中:
@[package:]drawable/filename
The following application code retrieves the image as a Drawable:以下应用程序代码将图像检索为 Drawable:
Resources res = getResources();
Drawable drawable = res.getDrawable(R.drawable.myimage);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.