【问题标题】:LinearLayout background not found未找到 LinearLayout 背景
【发布时间】:2015-12-18 14:49:44
【问题描述】:

我知道这个背景图片存在,它位于以下 drawable 文件夹中:

  • res/drawable-mdpi/
  • res/drawable-hdpi/
  • res/drawable-xhdpi/
  • res/drawable-xxhdpi/

该文件被命名为coming_up.9.png,因为它是一个九个补丁,我知道这是可行的,因为我正在对许多其他图像做同样的事情。

布局 XML

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/coming_up">

错误

Error:(213, 37) No resource found that matches the given name (at 'background' with value '@drawable/coming_up').

【问题讨论】:

    标签: android image android-studio android-drawable nine-patch


    【解决方案1】:

    我已经处理这个问题一段时间了,我决定今天是解决这个问题的日子。以下是我解决问题的方法:

    我采取的步骤:

    1. 将背景更改为名为 @drawable/checkbox_checked 的不同(工作)图像,看看会发生什么 - 应用在新图像上运行良好
    2. 在我的资源文件夹 /res 中搜索 checkbox_checked 以查看它的存在位置
    3. 发现checkbox_checked.png 只在/drawable 主文件夹中
    4. /drawable-mdpi 复制coming_up.9.png/drawable - 仍然是同样的错误
    5. coming_up.9.png 重命名为 coming_up.png - 工作
    6. coming_up.png 重命名为 coming_up.9.png - 仍然有效
    7. /drawable 中删除了 coming_up.9.png,同时将其保留在我所有其他可绘制文件夹中 - 有效

    这似乎是 Android Studio 的一个错误,在第 5 步以某种方式解决。不管这个问题已经解决了,所以我希望这可以节省我解决问题的时间。

    【讨论】:

      猜你喜欢
      • 2013-12-03
      • 2011-08-24
      • 1970-01-01
      • 2012-08-19
      • 2017-04-16
      • 2014-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多