简体   繁体   中英

How to change to material theme in android?

My application uses android:Theme.Light but as a theme in styles.xml. i would want to change it into a Material theme. Anyone assist me how to change it.

<resources>
    <style name="AppBaseTheme" parent="android:Theme.Light">
    </style>

    <style name="AppTheme" parent="AppBaseTheme">
    </style>
</resources>

I use this:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">yourcolorPrimary</item>
    <item name="colorPrimaryDark">yourcolorPrimaryDark</item>
    <item name="colorAccent">yourcolorAccent</item>
</style>

Material theme requires api level - 21. Refer this link to use material theme.

To use Material theme in app, which has min api level is less than 21, you need to use two values. One will be created by default other one is values-v21. So there will two values folder 'values' and 'values-v21'. Styles which contain in the 'value' directory will reflect in app which is running below lollipop phones. 'values-v21' will reflect in app which is running lollipop and above.

refer this link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM