Android L Change Theme Colors Error

2020-05-03 11:30发布

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>

4条回答
劫难
2楼-- · 2020-05-03 12:06

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.

查看更多
在下西门庆
3楼-- · 2020-05-03 12:08

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

查看更多
Root(大扎)
4楼-- · 2020-05-03 12:16

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

查看更多
孤傲高冷的网名
5楼-- · 2020-05-03 12:24

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.

查看更多
登录 后发表回答