且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

价值观,价值观,V11和价值观,V14文件夹样式和主题

更新时间:2023-02-27 11:09:21

  

更一般地,我的问题是,在这3个文件夹的工作作为家长   和孩子?

这些文件夹中有最具体的配套制度工作这意味着它会匹配最接近(下)API级别文件夹:

  • 值-V14 目标的API> = 14 (它不会在所有被选中的版本低于 14
  • 值-V11 目标之间(含)的API 11 13 如果值-V14 是present ,否则它将匹配每一个版本的开头 11 及以上的((它不会被选中在所有的以下版本 11 ))
  • 是默认的文件夹,这将是最后一个被匹配,覆盖未涉及的另一个值-XX 其它API级别code>文件夹。你应该总是(如同所有的资源文件夹)有这个文件夹中的应用程序
  

如果它确实是它工作的方式,是否有意义然后   设置样式父文件夹值的最大值和只添加   具体的人在V11或V14?

是的,这是怎样的Andr​​oid项目模板内置(当你使用新建项目... ),它实际上告诉了你使用值-XX 文件夹定制(不同的外观,采用了较新的款式,属性):

 <  - 在从V-14值的文件夹中的styles.xml: - >
 <! -  API 14主题自定义可以去这里。 - >
 

I am currently working on my app to base its design on the Holo theme. Globally what I want to do is working but I am a little confused about the way that are working the folders values, values-v11 and values-v14.

So I know that:

  • values is targeting the API inferior to 11
  • values-v11 is targeting the API between 11 and 13
  • values-v14 is targeting the API superior to 13

At first I thought I had to specify for every folder all the styles needed for the app but then I realized a kind of inheritance system was in place.

My problem is that I am really confused and don't understand clearly how is working this inheritance between these 3 folders.

I did the following test in order to see the behavior on my phone (running on Android 4.0, so the folder values-v14 should be the one loaded):

In values I have a style to set in blue the text color:

<style name="TextMedium" parent="@android:style/TextAppearance.Medium">
    <item name="android:textColor">@color/Blue</item>

In values-v11 I have a style to set in white the text color:

<style name="TextMedium" parent="@android:style/TextAppearance.Medium">
    <item name="android:textColor">@color/White</item>

In values-v14 I have a style to set in red the text color:

<style name="TextMedium" parent="@android:style/TextAppearance.Medium">
    <item name="android:textColor">@color/Red</item>

For the first case above (every folder with a different color), the color loaded on my text is red, meaning the values-v14 folder gets the priority.

Then if I comment out the red style from the values-v14 folder, the text becomes white. Does that mean that the system will take the style in the values-v11 folder even if the device is targeting the values-v14 folder? I thought it would maybe use the values folder by default but not values-v11.

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

  • If the device is running on a API version > 13, the system will load values-v14 then values-v11 and finally values.
  • If the device is running on a API between 11 and 13, the system will load values-v11 and then values.
  • If the device is running on a API version < 11, the system will load only values.

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?

Sorry for the long question, I hope it is clear, this themes/styles system is only described briefly in the Android guide and it is difficult to find information on how it works...

Thanks for your help!

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