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

转载: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. -->'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值