android:Theme.Material.Light需要API级别21(当前最小值为8) [英] android:Theme.Material.Light requires API level 21 (current min is 8)

查看:142
本文介绍了android:Theme.Material.Light需要API级别21(当前最小值为8)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在最低sdk版本为8的应用程序中使用Material Theme.根据文档-"material theme仅在Android 5.0(API级别21)及更高版本中可用.v7支持库为主题提供了material某些小部件的设计样式以及对自定义调色板的支持."如果我在项目中添加了v7支持Libarary,是否可以使用它?因为添加此库后,出现以下错误:

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需要API级别21(当前最小值为8).

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.

推荐答案

为此,您需要具有2个值文件夹.

For this you need to have 2 values folder.

一个默认存在,另一个,您必须在您的res文件夹中创建并将其命名为values-v21.

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

在默认值文件夹的styles.xml中,使用材质"主题以外的主题 在您创建的values-v21文件夹的styles.xml中,使用Material主题.

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

Android手机将自动提取其支持的styles.xml.如果手机支持Material Design设计(棒棒糖设备),则您的应用将使用Material主题(values-21文件夹).

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

如果没有(在运行旧版android的手机中),则将使用默认值文件夹.

if it doesnt (in phones running older android versions), the default values folder will be used.

这篇关于android:Theme.Material.Light需要API级别21(当前最小值为8)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆