Android应用图标作为属性

时间:2013-08-19 10:16:22

标签: android attr android-theme

我的 AndroidManifest.xml

中有以下内容
<application
            android:icon="@drawable/icon"
            android:label="@string/app_name"
            android:name=".MonamiqApplication"
            android:theme="@style/monamiq_theme">

这是有效的,但是我想为此使用一个属性,这可能是应用程序图标吗?我使用自定义主题,我已经定义了 app_icon

我想用

<application
            android:icon="?app_icon"
            android:label="@string/app_name"
            android:name=".MonamiqApplication"
            android:theme="@style/monamiq_theme">

attr.xml

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

monamiq_theme.xml

<resources>
    <style name="monamiq_theme" parent="android:Theme.Holo.Light" >
        <item name="app_icon">@drawable/icon</item>
    </style>

1 个答案:

答案 0 :(得分:0)

将新图标放在drawable文件夹中,清理项目并将其与@ drawable / your_image一起使用。只需替换默认值。