Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 设置在xml中使用的图像样式_Java_Android_Xml_Styles_Themes - Fatal编程技术网

Java 设置在xml中使用的图像样式

Java 设置在xml中使用的图像样式,java,android,xml,styles,themes,Java,Android,Xml,Styles,Themes,我正在尝试为我的应用程序设置主题更改选项。 我在这里读到了一些类似的问题,比如我的问题,但没有一个解决方案是有效的 在我的styles.xml中,我添加了: <style name="themeBackground"> <item name="android:src">@drawable/background2</item> </style> 我得到的错误是: Caused by: android.content.res.

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

在我的
styles.xml
中,我添加了:

<style name="themeBackground">
        <item name="android:src">@drawable/background2</item>
    </style>
我得到的错误是:

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”
,就像在其他帖子中建议的那样,但没有成功。有什么想法吗


谢谢

在res/values/dir中创建文件attrs.xml并添加代码:

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

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