简体   繁体   中英

Multiple styles.xml files in Android Studio

I recently imported my Android project from eclipse to Android Studio. I have 3 styles.xml files : styles.xml, styles.xml (v11) and styles.xml (v14). I don't know how and when did that happen.

styles.xml (v11) includes :

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

styles.xml (v14) includes :

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

What are they?

They work identically to your original styles.xml , but they have 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+.

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

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:

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

This means that you can define custom styles for each API, by default they are empty. This is useful when you want to specify styles for an API. Even you can also define styles for devices of different densities creating the styles.xml in folders named density. Example: values-mdpi, values-hdpi.

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