【问题标题】:setting styles images for use in xml设置样式图像以在 xml 中使用
【发布时间】:2013-02-04 12:41:20
【问题描述】:

我正在尝试为我的应用设置主题更改选项。 我在这里读到了一些类似的问题,但没有一个解决方案有效。

我添加到我的styles.xml

<style name="themeBackground">
        <item name="android:src">@drawable/background2</item>
    </style>

在我添加到layot的xml上:

android:background="@style/themeBackground"

我得到的错误:

Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060000 a=-1 r=0x7f060000}

我尝试按照其他帖子中的建议从清单中删除 - android:theme="@style/AppTheme",但没有成功。有什么想法吗?

谢谢!

【问题讨论】:

    标签: java android xml styles themes


    【解决方案1】:

    在 res/values/ 目录下创建文件 attrs.xml 并添加代码:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    <attr name="themeBackground" format="reference" />
    </resources>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-10
      • 2012-07-29
      • 1970-01-01
      • 2019-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多