简体   繁体   中英

Difference between values folders in Android

I am new to Android development and was looking for a good explanation of the different values folders in my project. such as values, values-sw600dp, values-sw720dp, values-v11, and values-v14. For example, if I want to say fit an older version of android which folder should I put a copy of my dimens.xml file? Thanks!

The default values folder would contain the resources to be used by default by your application.

values-v11 and values-v14 contain the resources to be used for API versions 11 and 14 respectively.

The application loads resources from the respective folders based on its API level.

  • values is meant for devices below API 11
  • values-v11 is meant for devices with API between 11 and 13
  • values-v14 is is meant for devices above API 13

If nothing is provided explicitly in the specific folders , then the default values folder is used.

Similarly, values-swXXXdp contain the specific resources based on the density and size of the device, if you are looking to implement different resources according to different device sizes. Again, if nothing is provided, the default values folder is used.

Here is the documentation which would be of help.

The key after the base resource folder name is used to provide alternative resources. There is a great explanation on the Android developer site about the types of alternative resources that are supported.

Anything with av# is for a specific android API level. swXXXdp are for specific device sizes.

You can say that the values folder is the default folder, and the contents of the other folders override the default it the condition is met.

For example, you can have a layout with 1 column in "res/layout". And then you make another layout with 2 columns in "res/layout-landscape". Then you start your activity and you see 1 column. When the condition is met (ie you put the phone in horizontal position) the layout changes to 2 columns.

You can specify resolutions, pixel densitys, API versions...

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