and*_*ubi 27 android android-layout android-studio
我在我的Android项目中添加了一个图像,我想在UI中使用它.我已将文件my-image.png添加到drawable目录(使用该项目创建的所有4个可绘制目录),并将其添加ImageView到布局中:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:layout_alignParentBottom="true"
android:layout_alignLeft="@+id/textView"
android:layout_marginBottom="63dp"
android:src="@drawable/my-image" />
Run Code Online (Sandbox Code Playgroud)
问题是我收到以下错误:
渲染问题
无法将@ drawable/my-image转换为drawable
这是捕获:

另外,如果我尝试编译项目,我会收到以下错误:
Gradle:任务':MyProject:processDebugResources'的执行失败.
为什么我会收到这些错误,如何解决?我错过了什么吗?我刚刚开始Android开发.
Tar*_*ngh 57
Gradle: Execution failed for task ':MyProject:processDebugResources'.
Run Code Online (Sandbox Code Playgroud)
因为您在参考资料中有命名约定错误
file name: must contain only [a-z0-9_.]
Run Code Online (Sandbox Code Playgroud)
将文件名重命名为 my_image
Rename this drawable @drawable/my-image to @drawable/my_image
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
39396 次 |
| 最近记录: |