Android Studio中的多个styles.xml文件

时间:2015-02-10 22:12:02

标签: android android-studio android-styles

我最近将我的Android项目从eclipse导入Android Studio。 我有3个styles.xml文件:styles.xml,styles.xml(v11)和styles.xml(v14)。我不知道这是怎么发生的,什么时候发生的。

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)包括:

<!--
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.
-->

我想知道他们为什么在这里以及我是否可以删除v11和v14 xml文件。

2 个答案:

答案 0 :(得分:4)

他们是什么?

它们与原始styles.xml的工作方式完全相同,但却有resource qualifiers。这意味着只有在符合条件时才会使用 - 在这种情况下,当API版本为11+或14 +时。

我可以删除它们吗?

- 如果它们是空的,则不会产生任何影响。


  

进一步阅读

     

如果您想了解更多信息,请take a look at this guide from Google

答案 1 :(得分:2)

默认情况下,您的应用使用styles.xml,但Eclipse在创建新项目时将styles.xml放在该文件夹中(v11和v14),请阅读每个文件的注释:

API 11+的基本应用程序主题。这个主题完全取代了 来自API 11+设备上res / values / styles.xml的AppBaseTheme。

这意味着您可以为每个API定义自定义样式,默认情况下它们是空的。当您要为API指定样式时,这非常有用。甚至您也可以为不同密度的设备定义样式,在名为density的文件夹中创建styles.xml。示例:values-mdpi,values-hdpi。