zoukankan      html  css  js  c++  java
  • 在SOUI中使用线性布局

    SOUI 2.5.1.1开始支持线性布局(LinearLayout).

    要在SOUI布局中使用线性布局, 需要在布局容器窗口里指定布局类型为vbox | hbox, (vbox为垂直线性布局, hbox为水平线性布局).

    在指定布局类型后还可以为容器窗口指定gravity属性, 用来指定子窗口的默认排列模式. vbox的gravity有:left(默认), center, right, hbox有: top(默认), center, bottom.

    在线性布局中的子窗口pos属性没有意义, 一般直接指定size="width,height", width/height值: -1代表wrap_content, -2代表match_parent

    可以使用layout_gravity可以更改当前窗口的排列模式.

    使用extend="left,top,right,bottom", extend_left, extend_top, extend_right, extend_bottom来指定间距. (相当于android的margin)

    子窗口支持使用weight属性.

    看下面demo中的例子:

    <page title="linear layout">
          <!--这里演示在SOUI中使用线性布局,在window中指定layout="vbox,hbox,linearLayout"时窗口的子窗口布局变成自动布局模式-->
          <window layout="vbox" size="-1,-1" colorBkgnd="#cccccc" gravity="center">
            <!--线性布局的自适应子窗口大小-->
            <text>vbox + gravity + wrapContent</text>
            <window size="100,30" colorBkgnd="#ff0000"/>
            <window size="200,30" extend="10,5,10,5" colorBkgnd="#ff0000"/>
            <window size="120,30" layout_gravity="right" colorBkgnd="#ff0000"/>
          </window>
    
          <window pos="0,[5,@-1,@200" layout="vbox" colorBkgnd="#cccccc">
            <!--线性布局的weight属性-->
            <text extend_bottom="10">vbox + gravity + weight</text>
            <window size="100,30" colorBkgnd="#ff0000"/>
            <window size="200,30" extend="10,5,10,5" colorBkgnd="#ff0000" weight="1"/>
            <window size="120,30" layout_gravity="right" colorBkgnd="#ff0000" weight="1"/>
            <button size="100,30" extend_top="10">button test</button>
          </window>
    
          <window pos="0,[5" layout="vbox" colorBkgnd="#cccccc" id="10000">
            <text extend_bottom="10" layout_gravity="center">hbox demo</text>
            <window size="-1,-1" layout="hbox" colorBkgnd="#888888">
              <!--线性布局之hbox-->
              <button size="100,30">button1</button>
              <button size="100,30" extend_left="10">button2</button>
              <button size="100,30" extend_left="10">button3</button>
              <button size="100,30" extend_left="10">button4</button>
            </window>
          </window>
        </page>
  • 相关阅读:
    Pandas高级教程之:category数据类型
    Pandas高级教程之:处理缺失数据
    Pandas高级教程之:处理text数据
    密码学系列之:blowfish对称密钥分组算法
    架构之:数据流架构
    ES6中的新特性:Iterables和iterators
    密码学系列之:feistel cipher
    Pandas高级教程之:Dataframe的重排和旋转
    Electron实用技巧-electron-builder中用户协议(license)的使用及多语言支持
    Electron实用技巧-开机启动时隐藏主窗口,只显示系统托盘
  • 原文地址:https://www.cnblogs.com/setoutsoft/p/6413442.html
Copyright © 2011-2022 走看看