理清android中values, values-v11, value-v14之间的关系

来源:互联网 发布:手机淘宝轮播图尺寸 编辑:程序博客网 时间:2024/04/29 14:11
http://blog.csdn.net/luofeixiongsix/article/details/48438093
(1)这三个folder是否是父子关系?
答案:不是,这个三个folder以匹配的方式进行工作。
values-14:针对API>=14以上的,API小于14,根本就用不到它。
value-11: 针对API在11以上和13以上的,如果values-14存在的话。如果values-14不存在,则API 11以上都要使用该文件夹。另外API在11一下则无法使用该文件夹。
values: 是缺省的文件夹且最后被匹配的,它包含在value是-11和values-14中没有包含的API水平。一般缺省都使用这个文件夹。
(2)是不是只需要在V11和V14指定特殊的,其他的全放在values就可以了?
答案:是


在国外的网站上找到这么一段话 (http://stackoverflow.com/questions/16624317/styles-and-themes-on-values-values-v11-and-values-v14-folders):


More generally, my question is, are these 3 folders working as parent and child?

Those folders work with a "most specific" matching system meaning it will match the closest(lower) API level values folder:

  • values-v14 targets APIs >= 14(it will not be selected at all for versions below 14)
  • values-v11 targets APIs between(and including) 11 and 13 if values-v14 is present otherwise it will match every version starting with 11 and above((it will not be selected at all for versions below 11))
  • values is the default folder and it will be the last to be matched, covering other APIs levels not covered by another values-xx folder. You should always(as with all resources folders) have this folder in your app

If it is indeed the way it is working, does it make sense then to setup the maximum of styles in the parent folder values and add only specific ones in v11 or v14?

Yes, this is how the Android project template is built(when you use Create new project...), it actually tells you to use the values-xx folders for customization(different look, use of newer styles, attributes):

 <!-- in the styles.xml from the v-14 values folder: --> <!-- API 14 theme customizations can go here. -->'
0 0