nim_duilib(2)之xml目录结构理解
introduction
- 本文将总结我对nim_duilib的xml配置。
- 更多控件和控件属性的具体说明, 请参考 here
before starting
1
You should clone the program named NIM_Duilib_Framework
2
open the NIM_Duilib_Framework\bin\bin\resources\themes\default folder.
lets go
- 基于上一篇, 已经创建了一个duilib的窗口了。 这个窗口使用的是basic.xml文件配置的UI,这个文件位于NIM_Duilib_Framework\bin\bin\resources\themes\default\basic目录下。
- 位于bin目录下的controls.exe出现的控件(按钮,label.......),使用的是controls.xml.
- controls.xml中的控件,这些控件的属性有些定义在了上一层目录下的global.xml中,比如,按钮的样式。 controls.xml中的按钮代码如下:
<Button class="btn_global_blue_80x30" text="blue"/>
<Button class="btn_global_white_80x30" text="white"/>
<Button class="btn_global_red_80x30" text="red"/>
看,这里的按钮出现了属性class, 一开始我也没明白这个属性。 后来发觉,class属性定义在了global.xml中:
<!--按钮-->
<Class name="btn_global_blue_80x30" font="system_bold_14" normaltextcolor="white" normalimage="file='../public/button/btn_global_blue_80x30_normal.png'" hotimage="file='../public/button/btn_global_blue_80x30_hovered.png'" pushedimage="file='../public/button/btn_global_blue_80x30_pushed.png'" disabledimage="file='../public/button/btn_global_blue_80x30_normal.png' fade='80'"/>
<Class name="btn_global_white_80x30" font="system_bold_14" normaltextcolor="dark_gray" normalimage="file='../public/button/btn_global_white_80x30_normal.png'" hotimage="file='../public/button/btn_global_white_80x30_hovered.png'" pushedimage="file='../public/button/btn_global_white_80x30_pushed.png'" disabledimage="file='../public/button/btn_global_white_80x30_normal.png' fade='128'"/>
<Class name="btn_global_red_80x30" font="system_bold_14" normaltextcolor="white" normalimage="file='../public/button/btn_global_red_80x30_normal.png'" hotimage="file='../public/button/btn_global_red_80x30_hovered.png'" pushedimage="file='../public/button/btn_global_red_80x30_pushed.png'" disabledimage="file='../public/button/btn_global_red_80x30_normal.png' fade='80'"/>
其中,设置了按钮的几种状态下的图片和图片透明度属性。当然,也可以将这些属性写在controls.xml中。
以btn_global_blue_80x30为例, controls.xml中的btn_global_blue_80x30需要与global.xml中btn_global_blue_80x30的结合看。
- 需要结合 controls.xml和global.xml文件,一起看, 熟悉常见控件的xml用法。
- 可以自己动手修改部分属性,看看效果。