价值观,价值观,V11和价值观,V14文件夹样式和主题 [英] Styles and themes on values, values-v11 and values-v14 folders
问题描述
我目前工作在我的应用程序基础及其对河洛主题设计。在全球范围内是我想要做的是工作,但我对那些工作的文件夹的方式有点糊涂值
,值-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
目标之间(含)的API11
和13
如果值-V14
是present ,否则它将匹配每一个版本的开头11
及以上的((它不会被选中在所有的以下版本11
)) -
值
是默认的文件夹,这将是最后一个被匹配,覆盖未涉及的另一个值-XX 其它API级别code>文件夹。你应该总是(如同所有的资源文件夹)有这个文件夹中的应用程序
如果它确实是它工作的方式,是否有意义然后 设置样式父文件夹值的最大值和只添加 具体的人在V11或V14?
是的,这是怎样的Android项目模板内置(当你使用新建项目...
),它实际上告诉了你使用值-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 11values-v11
is targeting the API between 11 and 13values-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
thenvalues-v11
and finallyvalues
. - If the device is running on a API between 11 and 13, the system will load
values-v11
and thenvalues
. - 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 below14
)values-v11
targets APIs between(and including)11
and13
ifvalues-v14
is present otherwise it will match every version starting with11
and above((it will not be selected at all for versions below11
))values
is the default folder and it will be the last to be matched, covering other APIs levels not covered by anothervalues-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屋!