Three major Flex layout usage (reprint)

Source: Internet
Author: User

Flex Layout Basics

For flex beginners, after Hello World, the flex layout is the gist of the next stop to learn. If you move from a traditional HTML, you always want to find controls like Div/table/ul and so on, and you want to be able to drag and drop controls like Dreamweaver in Flex, and if you're transitioning from a Windows application program, You might prefer the absolute layout so that the control is scattered over the page and the coordinates are controlled by x/Y. This makes the HTML Designer laugh, but I've seen someone do it with vs.

Like Div's friends, may think box is very kind, like with Table Designer, sorry, Flex no table,grid Although with the extreme image, but not used to layout; application programmers do not want to act, use absolute layout, This layout is not suitable for Web applications, and it doesn't matter if you're just developing a desktop version.

Three demos are written in this section:

Absolute layout

Hbox layout

VBox layout (referred to as the former box layout)

If you are developing an air program or desktop application, you can choose the absolute layout, but if you are developing a Web application, it is recommended to learn and study the box layout. Right-click to view source code.

Absolute of Flex Layout

When you create a new application with Flex, there is a layout property option at the bottom: Vertical,horizontal,absolute. Meaning is like a word. If you select Absolute, the application's child controls depend on their {x, y} coordinates. But does not affect the second generation of child controls, that is, if you put a hbox into the application, the controls in Hbox are arranged horizontally. Horizontal and vertical equivalent to the application as a horizontal or vertical box (box), the influence of the pair, sun control is similar to absolute.

Looking at the absolute, it is not difficult to find the width of the viewable area is certain, regardless of the resolution, what browser width. But in Web applications, we don't want to have this effect. Instead, we might want the control to automatically adjust the position as a percentage. This is the only way to develop a web app, and it is not recommended to use the absolute layout. This creates a convenient, simple and easy-to-use box layout.

Second, flex layout of the Hbox

Hbox allows child controls to be arranged horizontally, right, left, or centered.

View Hbox, control with the former without adding or subtracting, the same control. But it can be adapted to the browser width. The title bar section of the article uses a hbox, which includes three sub-controls: Label,spacer and Linkbutton.spacer width is set to 100%, so no matter how many characters of the Label, how wide, you can put LinkButton to the far right. Similarly, it can be used in VBox, then set its height to 100%. The spacer is very useful in the box layout.
Careful friend is not hard to find, this application layout attribute is vertical, the entire app is equivalent to a vbox. The bottom Comment text box and button are also within a hbox.

Iii. VBox of Flex layout

VBox let the child controls be arranged in a vertical direction. Top,bottom or center.

View VBox, the app's layout is horiazontal, equivalent to a hbox. The first level control is two VBox, one left and one right. The left side is similar to the part corresponding to the previous hbox. Right with panel and Titlewindow, and Grid,tile. Both the panel and the Titlewindow have the Layout property, which allows any child controls to be placed inside them, with the same treatment as application. It is worth mentioning that the tile, which allows the child control flow extension, first on the x-axis line, full and then wrap. Tilelist is similar.

The grid resembles the table in HTML, but it is very different and is not suitable for layout. In practical applications, tiles or tilelist are also used instead.
The box layout can accommodate basic project applications, but there are some issues. For example, the content of the article to scroll to show, can you implement the flow layout like HTML? The answer is yes. The box layout is just the basic layout method and does not play the strengths and benefits of flex. About state and flow layout at a later time.
In commercial project development, application99% uses absolute layouts, with box,tile or other layouts between the containers used in the middle.

Three major Flex layout usage (reprint)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.