我正在开发一个android-wear应用程序,并试图用图像覆盖文本。
在main_activity.xml中,我有:
<ImageView
android:id="@+id/myImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher1.png" />
<TextView
android:id="@+id/myImageViewText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/myImageView"
android:layout_alignTop="@id/myImageView"
android:layout_alignRight="@id/myImageView"
android:layout_alignBottom="@id/myImageView"
android:layout_margin="1dp"
android:gravity="center"
android:text="Hello"
android:textColor="#000000" />
android工作室抱怨
cannot resolve symbol @drawable/ic_launcher1.png
所以要修复我在文件夹中生成
refs.xml
refs.xml内容:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<drawable name="ic_launcher1.png">test</drawable>
</resources>
在哪里添加图像?
最佳答案
您不需要refs.xml
,但需要文件夹res
和res/drawable
以及文件ic_launcher1.png
位于可绘制文件夹中
Drawable Resources
你的xml必须是这样的
<ImageView
android:id="@+id/myImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher1" />