价值观,价值观,V11和价值观,V14文件夹样式和主题 [英] Styles and themes on values, values-v11 and values-v14 folders

查看:101
本文介绍了价值观,价值观,V11和价值观,V14文件夹样式和主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前工作在我的应用程序基础及其对河洛主题设计。在全球范围内是我想要做的是工作,但我对那些工作的文件夹的方式有点糊涂值-V11 值-V14

所以,我知道:

  • 瞄准的是API不如11
  • 值-V11 的目标是11和13
  • 之间的API
  • 值-V14 瞄准的是API优于13

起初我还以为我必须指定每个文件夹所需要的所有应用程序的样式,但后来我意识到一种继承制度已经到位。

我的问题是,我真的很困惑,不明白清楚是如何工作的这3个文件夹之间的继承关系。

我才能看到我的手机的行为下面的测试(在Android 4.0上运行,因此该文件夹值-V14 应了一句加载):

我有一个风格的蓝色的文字颜色设置​​:

 <样式名称=TextMedium父=@安卓风格/ TextAppearance.Medium>
    <项目名称=机器人:文字颜色> @色/蓝色< /项目>
 

值-V11 我有一个风格的白色文字颜色设置​​:

 <样式名称=TextMedium父=@安卓风格/ TextAppearance.Medium>
    <项目名称=机器人:文字颜色> @色/白< /项目>
 

值-V14 我有一个风格的红色文字颜色设置​​:

 <样式名称=TextMedium父=@安卓风格/ TextAppearance.Medium>
    <项目名称=机器人:文字颜色> @色/红色和LT; /项目>
 

有关上述第(每个文件夹用不同的颜色),第一种情况下,在我的文字加载的颜色是红色的,这意味着值-V14 文件夹中得到优先考虑。

那么,如果我注释掉红色风格从值-V14 文件夹,文本变为白色。这是否意味着,该系统会自动风格的值-V11 文件夹,即使该设备是针对值-V14 文件夹?我认为这将可能使用文件夹,默认情况下,而不是值-V11

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

  • 如果该设备上的API版本运行> 13时,系统会加载值-V14 然后值-V11 最后
  • 如果该设备已在11和13之间的API上运行时,系统会加载值-V11 然后
  • 如果该设备上的API版本&LT运行; 11,系统将只加载

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

对不起,长的问题,我希望它是明确的,这个主题/样式系统仅在Android指南简要介绍,这是很难找到它是如何工作的信息...

感谢您的帮助!

解决方案
  

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

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

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

如果它确实是它工作的方式,是否有意义然后   设置样式父文件夹值的最大值和只添加   具体的人在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. -->

这篇关于价值观,价值观,V11和价值观,V14文件夹样式和主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆