Android Studio在drawable属性中显示红色感叹号

时间:2015-10-09 03:13:22

标签: android xml android-layout android-studio

在布局XML文件中,红色感叹号显示在@drawable引用的左侧。几乎所有drawable都有这个标记:

enter image description here

shape_detail_btn_border.xml的内容如下。它是一组形状,没有任何破碎的图像资源:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
    <solid android:color="@android:color/white"/>
    <corners android:radius="5dp"/>
    <stroke android:width="1dp" android:color="@color/bapul_color_d5d5d5"/>
</shape>

我将鼠标悬停在标记上,没有显示任何内容。这是什么意思?

请注意,Android Studio版本为1.4(AI-141.2288178),目前是最新版本。并且,根本没有没问题来构建和运行应用程序。

2 个答案:

答案 0 :(得分:60)

简而言之,这不是代码中的错误。它告诉“Android Studio无法显示给定drawable的缩略图。”

感谢@Ramz在https://stackoverflow.com/a/33032200/361100找到答案。我将留下这篇文章,因为这个问题比链接的问题更具描述性。

答案 1 :(得分:0)

红色感叹号也出现在Java源文件中,其中引用了drawable。可以通过为R.drawable添加按需静态导入来消除它。例如:

import static com.mycompany.myapp.R.drawable.*;
相关问题