Sencha Touch 之 layout(布局)

一:HBox
水平纵向排列

代码:
Ext.application({
    name:  'MyApp' ,

    launch:  function () {
        Ext .create( 'Ext.Container'  ,{
            fullscreen:  true ,  //全屏
            layout:  'hbox' ,  //水平纵向布局
            items:[
                  {
                        xtype:  'panel' ,
                        html:  '消息列表'  ,
                        flex:1  //宽度所占比例为全屏的1/3
                  },
                  {
                        xtype:  'panel' ,
                        html:  '消息视图'  ,
                        flex:3
                  }
            ]
        })
    }  
});
二:VBox
水平横向(垂直)排列

代码:
Ext.application({
    name:  'MyApp' ,

    launch:  function () {
        Ext .create( 'Ext.Container'  ,{
            fullscreen:  true ,
            layout:  'vbox' ,
            items:[
                  {
                        xtype:  'panel' ,
                        html:  '消息列表'  ,
                        flex:1  //高度所占比为全屏高度的1/3
                  },
                  {
                        xtype:  'panel' ,
                        html:  '消息视图'  ,
                        flex:2
                  }
            ]
        })
    }  
});
三:Fit
子组件适应父类容器的全尺寸(全屏)

代码:
Ext.application({
    name:  'MyApp' ,
    launch:  function () {
        var  panel = Ext .create( 'Ext.Panel'  ,{
            width:200,
            height:200,
            layout:  'fit' ,  //充满父类窗口
            items:[
                  {
                        xtype:  'panel' ,
                        html:  'Also 200px by 200px'
                  }
            ]
        });
      Ext .Viewport.add(panel);
    }  
});
四:Docking(对接)
水平纵向对接

代码:
Ext.application({
    name:  'MyApp' ,
    launch:  function () {
        var  panel = Ext .create( 'Ext.Container'  ,{
            fullscreen:  true ,
            layout:  'hbox' ,
            items:[
                  {
                        docked:  'top' ,   //对接位置
                        xtype:  'panel' ,
                        height:  '50' ,
                        html:  'This is docked to the top'
                  },
                  {
                        xtype:  'panel' ,
                        html:  '消息列表'  ,
                        flex:1
                  },
                  {
                        xtype:  'panel' ,
                        html:  '消息视图'  ,
                        flex:2
                  }
            ]
        });
    }  
});
水平纵向对接

代码:
Ext.application({
    name:  'MyApp' ,
    launch:  function () {
        var  panel = Ext .create( 'Ext.Container'  ,{
            fullscreen:  true ,
            layout:  'hbox' ,
            items:[
                  {
                        docked:  'left' ,   //对接位置
                        xtype:  'panel' ,
                        height:  '50' ,
                        html:  'This is docked to the top'
                  },
                  {
                        xtype:  'panel' ,
                        html:  '消息列表'  ,
                        flex:1
                  },
                  {
                        xtype:  'panel' ,
                        html:  '消息视图'  ,
                        flex:2
                  }
            ]
        });
    }  
});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值