简体   繁体   English

Android Studio中的多个styles.xml文件

[英]Multiple styles.xml files in Android Studio

I recently imported my Android project from eclipse to Android Studio. 我最近将我的Android项目从eclipse导入Android Studio。 I have 3 styles.xml files : styles.xml, styles.xml (v11) and styles.xml (v14). 我有3个styles.xml文件:styles.xml,styles.xml(v11)和styles.xml(v14)。 I don't know how and when did that happen. 我不知道这是怎么发生的,什么时候发生的。

styles.xml (v11) includes : styles.xml(v11)包括:

<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->

styles.xml (v14) includes : styles.xml(v14)包括:

<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and 
res/values-v11/styles.xml on API 14+ devices.
-->

I want to know why are they here and whether or not i can delete the v11 and v14 xml files. 我想知道为什么他们在这里以及我是否可以删除v11和v14 xml文件。

What are they? 这些是什么?

They work identically to your original styles.xml , but they have resource qualifiers . 它们与原始styles.xml工作方式相同,但它们具有resource qualifiers This means that they only get used when their qualifiers are met - in this case when the API version is 11+ or 14+. 这意味着它们仅在满足其限定符时才会被使用 - 在这种情况下,当API版本为11+或14+时。

Can I delete them? 我可以删除它们吗?

Yes - if they are empty then there will be no impact. 是的 - 如果它们是空的那么就没有影响。


Further Reading 进一步阅读

If you want to learn more then take a look at this guide from Google 如果您想了解更多信息, 请查看Google提供的本指南

By default your app uses styles.xml, but Eclipse when create new projects put styles.xml in that folders (v11 and v14), read the comment of each file: 默认情况下,您的应用程序使用styles.xml,但Eclipse在创建新项目时将styles.xml放在该文件夹中(v11和v14),读取每个文件的注释:

Base application theme for API 11+. API 11+的基本应用程序主题。 This theme completely replaces AppBaseTheme from res/values/styles.xml on API 11+ devices. 此主题完全取代API 11+设备上的res / values / styles.xml中的AppBaseTheme。

This means that you can define custom styles for each API, by default they are empty. 这意味着您可以为每个API定义自定义样式,默认情况下它们是空的。 This is useful when you want to specify styles for an API. 当您要为API指定样式时,这非常有用。 Even you can also define styles for devices of different densities creating the styles.xml in folders named density. 甚至您也可以为不同密度的设备定义样式,在名为density的文件夹中创建styles.xml。 Example: values-mdpi, values-hdpi. 示例:values-mdpi,values-hdpi。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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