如何在 Android 中使用多个 xml "style sheets"?
How do I use multiple xml "style sheets" in Android?
我想在 Android 项目中使用多个 xml 样式表。
我有:
res/
values/
styles.xml
some_other_styles_file.xml
and_some_other_styles_file.xml
...
什么是正确的方法:
1 - 引用那些文件
2 - 引用不同文件中的各个样式
并且:
3 - 如果使用多个 xml 样式表,样式名称是否需要在文件中是唯一的?换句话说,应用程序使用的两个文件是否可以包含同名样式?
文件名仅适用于您的组织,它们都是 自动 编译并由 R.style.<style_name>
在 java[= 时引用27=],或在 xml 时按 style = "@style/<style_name>"
(例如布局文件)。您甚至可以混合类型(例如,在您的 styles.xml 中有字符串资源)
To create a set of styles, save an XML file in the res/values/
directory of your project. The name of the XML file is arbitrary, but
it must use the .xml extension and be saved in the res/values/ folder.
The root node of the XML file must be <resources>
.
- 你用同样的方式引用它们
R.style.<style_name>
- 样式定义在哪个文件中无关紧要(文件用于组织)
- 是的,名称必须是唯一的。
我想在 Android 项目中使用多个 xml 样式表。
我有:
res/
values/
styles.xml
some_other_styles_file.xml
and_some_other_styles_file.xml
...
什么是正确的方法:
1 - 引用那些文件
2 - 引用不同文件中的各个样式
并且:
3 - 如果使用多个 xml 样式表,样式名称是否需要在文件中是唯一的?换句话说,应用程序使用的两个文件是否可以包含同名样式?
文件名仅适用于您的组织,它们都是 自动 编译并由 R.style.<style_name>
在 java[= 时引用27=],或在 xml 时按 style = "@style/<style_name>"
(例如布局文件)。您甚至可以混合类型(例如,在您的 styles.xml 中有字符串资源)
To create a set of styles, save an XML file in the res/values/ directory of your project. The name of the XML file is arbitrary, but it must use the .xml extension and be saved in the res/values/ folder.
The root node of the XML file must be
<resources>
.
- 你用同样的方式引用它们
R.style.<style_name>
- 样式定义在哪个文件中无关紧要(文件用于组织)
- 是的,名称必须是唯一的。