现在的位置: 首页 > 综合 > 正文

UI库阶段性进展(完成文字列表,样式列表(样式列表可继承))

2011年11月03日 ⁄ 综合 ⁄ 共 1654字 ⁄ 字号 评论关闭

xml文件共5个:animation.xml(暂不做解释)

                     dialog.xml

                     stringtable.xml

                     style.xml

                     testbutton.xml

 

style引用,stringtable引用的内容和关系大致如下:

1 <panel name="testbutton" pos="5,-105,-5,-5" style="panel">
2   <button name="colorbtn1" pos="5,4,45,35" txt="STR|colorbtn1" style="btncolor1"/>
3   <button name="colorbtn2" pos="50,4,90,35" txt="STR|colorbtn2" style="btncolor2"/>
4   <button name="imgbtn1" pos="100,5,150,35" txt="STR|imgbtn1" style="btnimg1"/>
5   <button name="imgbtn2" pos="155,5,265,45" txt="STR|imgbtn2" style="btnimg2"/>
6   <button name="imgbtn3" pos="270,5,330,35" txt="STR|imgbtn3" style="btnimg3"/>
7 </panel>

上面代码中明显一个按钮的描述减少了很多,其中style属性所描述的内容在style.xml中;

 1 <style name="panel">
 2   <att name="bgmode" value="2"/>
 3   <att name="bgimg" value="panelbg.png"/>
 4   <att name="bgstretch" value="5,5,5,5"/>
 5   <att name="fcolor" value="FF000000"/>
 6 </style>
 7 <style name="btncolor1">
 8   <att name="bgmode" value="0"/>
 9   <att name="bgcolor" value="FFFF0000"/>
10   <att name="bghovercolor" value="FF00FF00"/>
11 </style>
12 <style name="btncolor2" inherit="btncolor1"><!--注意可继承-->
13   <att name="disable" value="1"/>
14 </style>
15 <style name="btnimg1">
16   <att name="fcolor" value="FF00FF00"/>
17   <att name="bgmode" value="1"/>
18   <att name="bgimg" value="btnbg.png"/>
19 </style>
20 <style name="btnimg2">
21   <att name="fcolor" value="FF00FF00"/>
22   <att name="bgmode" value="2"/>
23   <att name="bgimg" value="btnbg.png"/>
24   <att name="bgstretch" value="5,5,5,5"/>
25 </style>
26 <style name="btnimg3" inherit="btnimg2">
27   <att name="disable" value="1"/>
28 </style>

注意:style的属性内容是支持继承的,呵呵,可以减少xml的量,增加解析速度;

另外button上的文字:

txt="STR|imgbtn3"

支持从stringtable索引,"STR|"是关键字,表示是索引字符列表中的问题,也可以直接填写文字就好;

这样一来关于xml配置基本就绪;

下面的计划是开始设计换肤,换色调,换文字的功能(这些都是基本支持框架,需要在开始大批量写控件前准备就许,不然到后面在弄就尾大不掉了);


抱歉!评论已关闭.