Android L Change Theme Colors Error

a 夏天 提交于 2019-12-02 19:14:57

问题


I've been following the new steps for Android L here: http://developer.android.com/preview/material/theme.html I've have been trying to change the colors of the status bar but it doesn't work.

My styles.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:style/Theme.Material.Light">
<!-- Main theme colors -->
<!--   your apps branding color (for the app bar) -->
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="android:colorPrimary">@color/primary</item>
<!--   darker variant of colorPrimary (for status bar, contextual app bars) -->
<!--   theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">@color/accent</item>
</style>
</resources>

My colors.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primary">#03a9f4</color>
<color name="primary_dark">#0091ea</color>
<color name="accent">#e1f5fe</color>
</resources>

回答1:


I have the same problem. And I fix this by change sdk to

<uses-sdk android:minSdkVersion="L" android:targetSdkVersion="L" />

Hope it can help.




回答2:


I made it work by changing the style name in styles.xml and in AndroidManifest.xml.




回答3:


I don't have enough rep to elaborate upon @Allavaz's answer, but his solution worked for me. I changed the generated theme name in both styles.xml and AndroidManifest.xml from AppTheme to a different name.

I'm using Android Studio 0.8.2.




回答4:


as of oct 2014, It will not be visible in the layout preview but works when viewed inside on the emulator.



来源:https://stackoverflow.com/questions/24491643/android-l-change-theme-colors-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!