Pages

Wednesday, May 19, 2010

Android Layout

UI design, the use of XML (class XML) language to describe a major trend. AS in the interface UI part of the class XML, Microsoft's WPF and Silverlight also used XML language classes, of course, on the page XHTML is XML largest applied. Perhaps it is because Google is the reason the Internet has grown, so Android interface layout can be seen everywhere in the shadow of page layout. When you see findViewById would want to js frequently used document.getElementById do? When you use LinearLayout / RelativeLayout / TableLayou will think of the layout of the page DIV + CSS and the classic Table layout do? 
The following outlines a few key layout Android 

1, LinearLayout LinearLayout is a kind of assembly line-type layout. It can set the orientation property of the linear arrangement of the vertical direction (vertical) or vertical (horizontal). 
Two kinds of layout diagram 


2, RelativeLayout 
RelativeLayout (relative distribution) is a very flexible layout model has almost never seen could be original Android. The layout of a point is inside the control so you can specify the upper and lower alignment control. So we should set up such as: layout_alignBottom , layout_toRightOf, etc. properties. 
Some commonly used to describe the property: 
layout_toRightOf / layout_toLeftOf - Compact on the right / left controls. attribute value specified control id 
layout_alignTop / layout_alignBottom / layout_alignRight / layout_alignLeft - top / bottom / right / left alignment control 
layout_above - tight controls on it. attribute value specified control id 

layout_alignParentTop / layout_alignParentBottom - whether close to the parent container of the top / bottom 
layout_alignParentRight / layout_alignParentLeft - whether close to the parent container of the right / left side 

Schematic layout of the next RelativeLayout 



3, AbsoluteLayout 
Absolute layout is the layout of the application UI layout of the most widely used method is to specify the control of the X / Y coordinates so that the control fixed on a point. Windows programmers developed almost all of this layout. However, this layout in mobile phone development There are significant drawbacks, since different types of screen size of mobile phones may be exactly the same, which is j2me mobile developers are doing when the headache of different places. 
Andorid description of the control X / Y coordinates of the attributes are: layout_x, layout_y. 
X / Y coordinates of measurement units in the Android has the following categories: 
px: pixel 
dip: rely on the device pixel. This is the original android. 
sp: the proportion of pixels 
pt: Point 
in: feet 
mm: mm 

AbsoluteLayout layout diagram 

4, TableLayout 
Table layout in web design is a very common layout. But Android's TableLayout and page layout of the table is not the same. The following is the layout TableLayout several important attributes and objects 
collpaseColumns - hide TableLayout li TableRow column X 
stretchColumns - is set to be stretching out in columns X 
shrinkColumns - is set out in X to be contracted out 
TableRow - row object 
TableLayout Map 

No comments:

Post a Comment