1 Star 0 Fork 340

tgw / awtk

forked from zlgopen / awtk 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
how_to_write_layout_params_in_style.md 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
lixianjing 提交于 2021-05-11 15:50 . update docs

如何在窗体样式文件中写控件布局参数

一个控件在多个界面出现,而且它的布局参数是一样的,可以把它布局参数放到 style 中,这样可以提高可维护性。

一、在 style 中指定布局参数

示例:

<column>
  <style name="buttons" children_layout="default(row=4,col=1,spacing=10)"                        self_layout="default(x=center,y=10,w=50%,h=148)">
    <normal />
  </style>
</column>

完整示例请参考 styles/button.xml

二、在 UI 文件中引用

示例:

  <column style="buttons">
    <button name="open:dialog1" style="round" enable_long_press="true" text="Long Press"/>
    <button style="red_btn" text="Text"/>
    <button style="icon" text="Fullscreen" name="fullscreen"/>
    <button >
      <label y="0" x="0" w="100%" h="100%" text="Text"/>
      <image image="earth" draw_type="icon" y="0" x="right" w="30" h="100%"/>
    </button>
  </column>

完整示例请参考 ui/button.xml

C
1
https://gitee.com/tuguiwang/awtk.git
git@gitee.com:tuguiwang/awtk.git
tuguiwang
awtk
awtk
master

搜索帮助