android - 无法将可绘制对象转换为可绘制对象

标签 android android-studio android-imageview

我收到错误消息“无法将 @drawable/12234 转换为可绘制对象”,其中 12234 是我的图像名称,它位于可绘制对象文件夹中。

我可以分配其他较小的图像,但是当我尝试分配此图像时出现错误。

这是我的 Imageview xml 代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" 
    android:layout_height="match_parent">

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView4"
    android:layout_alignParentTop="true"
    android:src="@drawable/12234"
    android:adjustViewBounds="true"
    android:longClickable="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentBottom="true" />

最佳答案

根据文档可绘制资源必须满足以下条件:

基于文件的资源名称只能包含小写的 a-z、0-9 或 _。

而且在您的情况下,它不能全是数字,它必须至少有一个字母。

关于android - 无法将可绘制对象转换为可绘制对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29724519/

相关文章:

android - AppCompat v7 r21 更改 ActionBar 标题的 Alpha

android - WebView重置缩放设置

Android Studio classes.dex(拒绝访问)

android - 如何旋转或缩放ImageView的图像?

android - 删除 ImageView 的阴影

java - 代码中最好的 "identifying markers"有助于快速导航到代码中的某个位置?

java - 尝试设置 Preference 的 setTitle() 时出现 NullPointerException

android - 如何在 Android 的 textinputLayout 中设置 * in hint

android - 将 android 项目从 eclipse 迁移到 android studio 时出现 "Gradle location is incorrect"

java - 从 strings.xml 提供 layout_height 和 layout_width