无法将drawable转换为drawable

问题描述 投票:1回答:4

我收到错误“无法将@ drawable / 12234转换成drawable”,其中12234是我的图像名称,放在drawable文件夹中。

我能够分配更小的其他图像,但是当我尝试分配此图像时,它会给我一个错误。

这是我的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" />

android android-studio android-imageview
4个回答
9
投票

根据文件,drawables资源必须满足以下条件:

File-based resource names must contain only lowercase a-z, 0-9, or _.

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


0
投票

我通过重命名图像以首先拥有一个角色来解决了这个问题。

将图像名称从12234.jpg更改为r12234.jpg


0
投票

在Adroid Studio的设计视图中,只需单击刷新图标,即看起来像两个彼此面对的弯曲箭头的图标。这对我有用 - 我不需要重命名任何东西或重启我的电脑。我正在运行Ver 1.5.1,Marshmallow,API 23。


0
投票

我已经磕磕绊绊了几个小时,几乎所有问题的答案都读了,但没有任何效果。最后,我找到了一个有效的解决方案。

我做了什么

  • 在资源管理器中显示“可绘制”
  • 用我的替换ALLıs(drawable-hdpı - > drawable-hdpi,重命名所有文件夹)然后文件夹没有出现在android studio中
  • 用ı's替换了2个i(drawable-hdpi - > drawable-hdpı,重命名为2个文件夹)之后,所有图像开始出现,最后我能够添加图像。
© www.soinside.com 2019 - 2024. All rights reserved.