Android Studio xml 未将 png 转换为可绘制对象

标签 android xml android-studio

我有一个相当奇怪的问题,在我的 Android Studio 的可绘制项目文件夹中,我复制了一个 .png Material (从这里 https://design.google.com/icons/index.html#ic_settings_remote )。我将其命名为 connect.png。在主要 Activity 中,我通过以下方式引用它:

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"

    android:src="@drawable/connect.png" />

最后一行,ofc。它吐出 2 个错误: 无法解析资源 "@android:drawable/connect.png" 无法转换 "@android:@drawable/connect.png" 我试图解决这个问题:

  1. 重启 Android Studio
  2. 重新复制drawable文件夹中的素材资源
  3. 转到构建->清理项目 所有这些都没有用,我期待着您的回答。

最佳答案

尝试一下(没有 .png):

android:src="@drawable/connect"

关于Android Studio xml 未将 png 转换为可绘制对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35779073/

相关文章:

android - 获取Android中虚拟键盘的高度

html - 我是否需要使用 XHTML 文档类型在页面上声明 XML?

调试代码块完成时关闭Android应用程序

firebase - Flutter Firebase 错误(任务 ':app:mergeExtDexDebug' 执行失败)

android - android.unitTests.returnDefaultValues 是如何工作的?

java - 将持续时间从字符串转换为 float

xml - 拆分 apache Camel 后恢复 header 值

android - 切换分支不更新android studio

android - Activity 不会在 android 中更改的选项卡上重新启动

android - 以编程方式将 Fragment 添加到 Kotlin 中的 Activity