Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
242 views
in Technique[技术] by (71.8m points)

android:Theme.Material.Light requires API level 21 (current min is 8)

I want to use Material Theme in my application which has minimum sdk version of 8. As per docs - "The material theme is only available in Android 5.0 (API level 21) and above. The v7 Support Libraries provide themes with material design styles for some widgets and support for customizing the color palette." Does it mean I can use it if I add v7 Support Libarary in my project? Because after adding this library I got the following error:

android:Theme.Material.Light requires API level 21 (current min is 8).

Or maybe I understood something wrong? Any suggestion will be appreciated. Thanks in advance.

question from:https://stackoverflow.com/questions/26990021/androidtheme-material-light-requires-api-level-21-current-min-is-8

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

For this you need to have 2 values folders.

One that exists by default, and another, you have to create in your res folder and name it values-v21.

In the default values folder, in styles.xml, use a theme other than Material theme. And in the styles.xml of values-v21 folder that you created, use Material theme.

Android phone will automatically pickup the styles.xml which it supports. If the phone supports Material Design (Lollipop devices), your app will use Material theme (values-21 folder).

If it doesn't (in phones running older Android versions), the default values folder will be used.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...