Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.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
Android 如何设置主题中的图像样式。安卓_Android_Themes - Fatal编程技术网

Android 如何设置主题中的图像样式。安卓

Android 如何设置主题中的图像样式。安卓,android,themes,Android,Themes,我正在制作一个多主题应用程序,我希望将“色调”属性设置为当前主题中的所有图像 像这样 <style name="AppTheme.Default" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="colorPrimary">#EA7819</item> <item name="colorPrimaryDark">#CF6415</ite

我正在制作一个多主题应用程序,我希望将“色调”属性设置为当前主题中的所有图像

像这样

    <style name="AppTheme.Default" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">#EA7819</item>
        <item name="colorPrimaryDark">#CF6415</item>
        <item name="colorAccent">#3498DB</item>

        <item name="toolbarStyle">@style/Theme.AppCompat</item>
    </style>

#EA7819
#CF6415
#3498DB
@style/Theme.AppCompat

我可以在主题中设置工具栏样式,我可以对imageView执行类似操作吗?

您必须在每个
imageView
中设置色调颜色,如下所示:

// define your attr
<resources>
   <attr name="image_tint_color" format="reference"/>
</resources>
// create multiple themes: YourTheme1, YourTHeme2...
<style name="YourTheme1" parent="Theme.AppCompat.Light.DarkActionBar">
   <item name="image_tint_color">yourColor</item>
</style>
// After setting theme in activity:
setTheme(R.style.yourTheme1)
// Then you can use the color everywhere:
android:tint="?attr/image_tint_color"
//定义属性

对不起,当然是
tint
wow,真的非常感谢!我不知道,这可能会定义一个自定义属性