【翻译】The Layout System 布局

In Sencha Touch there are two basic building blocks: componentsand containers. When

you instantiate both with no configuration, they look the same. However, there is one

important difference: containers can containcomponents (or other containers):

在Sencha Touch中,有两个基本模块:组件(Components)容器(Contaniners),如果不靠配置去实例化他们,也许你会发现他俩没啥区别,但是我要指出的是他们之间最大的不同便是,容器可以包含组件。

var container = Ext.create('Ext.Container', {
items: [{
xtype: 'component',
html: 'Nested component'
}, {
xtype: 'container',
items: [{
xtype: 'component',
html: 'Nested container with component'
}]
}]
});

Usually when containers hold other components, you want to think about how to po‐

sition these multiple components. Maybe you want to position the components on top

of each other, or maybe next to each other. In other words, you want to give the container

a layout.

通常来说,当容器内含有其他组件的时候,你需要思考如何定位这么多的组件,也许你想将他们排列在Top,也许你想将他们并排排列,换句话说,你想要一个布局。

Under the hood, Sencha Touch uses the CSS3 flexbox layout. This is different from Ext

JS 4, which uses JavaScript to dynamically calculate absolute CSS positions. The reason

for the difference is because Ext JS needs to support old legacy browsers (IE6, ouch!).

CSS3 flexbox layouts work only in modern browsers, and even here, there are multiple

implementations required to support multiple browsers. To understand CSS3 flexbox

layouts, take a look at “A Complete Guide to Flexbox”.

While implementing layouts in Sencha Touch (and in Ext JS), you do not need to worry

about the underlying CSS techniques—the framework takes care of it. That said, some

concepts, like flexing boxes in Sencha Touch (dynamic sizing), are similar to the CSS3

flexbox techniques

在底层,Sencha Touch使用Css3的FlexBox布局,这不同于以前的ExtJs4,后者因为要兼容老的浏览器,所以要利用Js去动态实现CSS定位,而Flex布局只运行在现代浏览器上,为了支持多种浏览器,css3提供了多种实现。

Ext.Componentis the base class for any Sencha Touch view component (widget).

Ext.Containeris the base class for any Sencha Touch component that may visually

contain other components. The most commonly used container classes for Sencha

Touch are Ext.Panel, Ext.tab.Panel, and Ext.form.Panel.Containers handle the

basic behavior for containing, inserting, showing, removing, and hiding items.

Ext.Component是SenchaTouch 视图组件(widget)中最基础的类,

Ext.Container是SenchaTouch 中包围着component(组件)的一种容器,通常用到的容器有Ext.panel, Ext.tab.Panel,Ext.form.Panel,容器拥有自己的操作方法,比如包含(containing)、插入(inserting)、显示(showing)、隐藏(hiding)、删除(removing)各种组件。

Speaking

of containing items, you might want to position items next to each other, or even on

top of each other. Some items should be bigger than others. You might want to give

those a fixed width and height, or even better, a height and width relative to the screen

size. You can achieve all of this while working with layouts. To make this concept clear,

we’ll see some screenshots of all the different layout types. The next examples explain

all the different layout types provided by the layout package.

对于被包含的组件来说,你可能想要去定位他们,摆放他们,或者是都放在Top层,一些组件可能比其它组件大和高,显得不是很协调,此时,你就需要去自适应宽度和高度,或者做的更好一些,就需要根据屏幕去自适应,你通过布局实现这一切你想要的效果,通过这一章节,我们会看到不同的页面布局效果,下一节我将讲解不同的布局类所带来的不同的布局方案

In this chapter, you’ll learn:

  • How to implement a horizontal layout
  • How to implement a vertical layout
  • How to implement a full screen (fit) layout
  • How to implement a card layout
  • How to implement the default layout (no layout)
  • How to dock components

在这个章节,你将学到

  • 怎么实现一个横向布局
  • 怎么实现一个竖向布局
  • 怎么实现一个全屏(自适应)布局
  • 怎么实现一个卡片布局
  • 怎么实现一个默认布局(无布局)
  • 怎么dock组件 (dock是固定在某个位置,比如Top或者Bottom)
  • Hands-on Sencha Touch2 中文翻译

@落雨 ae6623.cn

【翻译】Sencha Touch2.4 The Layout System 布局的更多相关文章

  1. 【翻译】在Ext JS和Sencha Touch中创建自己定义布局

    原文:Creating Custom Layouts in Ext JS and Sencha Touch 布局系统是Sencha框架中最强大和最独特的一部分.布局会处理应用程序中每个组件的大小和位置 ...

  2. [前端]使用JQuery UI Layout Plug-in布局 - wolfy

    引言 使用JQuery UI Layout Plug-in布局框架实现快速布局,用起来还是挺方便的,稍微研究了一下,就能上手,关于该布局框架的材料,网上也挺多的.在项目中也使用到了,不过那是前端的工作 ...

  3. Understanding the WPF Layout System

    Many people don't understand how the WPF layout system works, or how that knowledge can help them in ...

  4. 从 Auto Layout 的布局算法谈性能

    这是使用 ASDK 性能调优系列的第二篇文章,前一篇文章中讲到了如何提升 iOS 应用的渲染性能,你可以点击 这里 了解这部分的内容. http://t.cn/Rc4KbUC 在上一篇文章中,我们提到 ...

  5. JQuery UI Layout Plug-in布局

    端]使用JQuery UI Layout Plug-in布局   引言 使用JQuery UI Layout Plug-in布局框架实现快速布局,用起来还是挺方便的,稍微研究了一下,就能上手,关于该布 ...

  6. Sencha Touch2 工作笔记

    Sencha Touch2 工作笔记 Ext.dataview.List activate( this, newActiveItem, oldActiveItem, eOpts ) Fires whe ...

  7. [前端]使用JQuery UI Layout Plug-in布局

    引言 使用JQuery UI Layout Plug-in布局框架实现快速布局,用起来还是挺方便的,稍微研究了一下,就能上手,关于该布局框架的材料,网上也挺多的.在项目中也使用到了,不过那是前端的工作 ...

  8. Sencha Touch2 -- 11.1:定义具有关联关系的模型

    在Sencha Touch2.0中,可以定义不同模型之间的关联关系.例如,在开发博客网站的时候,可以首先定义用户(User)模型,然后为用户定义文章(Article)模型.一个用户可以发表多篇文章,因 ...

  9. 【BZOJ1731】[Usaco2005 dec]Layout 排队布局 差分约束

    [BZOJ1731][Usaco2005 dec]Layout 排队布局 Description Like everyone else, cows like to stand close to the ...

随机推荐

  1. 了解Unix进程(2)

    1. 每个进程都有一个名字,crusher 可以得到: # process name puts $PROGRAM_NAME 10.downto(1) do | num | $PROGRAM_NAME ...

  2. STM32F0_新建软件工程详细过程

    前言 由于ST公司推出比STM32F1性价比更高的F0芯片,现在市面上F0芯片的占有率也非常高.F0芯片属于M0内核,主频48M(当然,可以超频的,但尽量不要超的太多),资源大小可根据项目需求来选型. ...

  3. RF-BM-S02(V1.0)蓝牙4.0模块 使用手册

    一.产品概述 图1 RF-BM-S02纯硬件模块 RF-BM-S02是一款采用美国德州仪器TI 蓝牙4.0 CC2540作为核心处理器的高性能.超低功耗(Bluetooth Low Energy)射频 ...

  4. 编译android程序时DEX过程出现错误

    今天编译高级设置时出现了错误,这好坑爹啊~ 于是我开始检查代码,发现代码没有错误啊,然后观察MAKE的步骤才发现是DEX时出现了问题!! 下面是错误的LOG: Information:Using ja ...

  5. mysql Unknown table engine 'InnoDB'解决办法

    最近做项目时,由于数据库存的中文乱码.改了一下配置.中文乱码改过来了,但是在导入数据时Unknown table engine 'InnoDB'  百度上各种拷贝.最后看了下InnoDB.是一种支持事 ...

  6. instanceof、==号、Objetc类

    1)instanceof: 判断某个对象是否为某个类的实例,注意多态的运用,一个父类引用指向子类的对象,根据继承,子类就是父类,所以子类也可以看做是父类的一个实例.  形式:引用 instanceof ...

  7. C扩展 C++回顾到入门

    引言 C扩展也称C++, 是一个复(za)杂(ji)优(ken)秀(die)的语言. 本文通过开发中常用C++方式来了解和回顾C++这么语言. C++看了较多的书但还是觉得什么都不会. 只能说自己还付 ...

  8. Android Service学习之本地服务

    Service是在一段不定的时间运行在后台,不和用户交互应用组件.每个Service必须在manifest中 通过来声明.可以通过contect.startservice和contect.bindse ...

  9. URI与URL的区别

    (原网址:http://zhidao.baidu.com/question/38764759.html) Web上可用的每种资源 - HTML文档.图像.视频片段.程序等 - 由一个通过通用资源标志符 ...

  10. C++11 常用语法

    1 新类型 C++ 11新增了long long和unsigned long long,以支持64bit宽度: 新增char16_t和char32_t以支持16位和32位字符表示: 增加了“原始”字符 ...