This example introduces the use of LinearLayout and Absolutelayout in Android, hoping to help a novice Android friend. The specific contents are as follows:
Android's UI layout is layout as a container, and it arranges the controls as specified above, which is similar to the Java Swing and Lwuit. Controls and layout have many properties that are the same, can be modified in properties, and the. Net/delphi and other rad similar, where the most commonly used properties have the following:
Id= "@+id/edtinput", ID is a bridge linking UI to code
gravity= "Center", center of Control in Layout
Layout_width= "Fill_parent", automatically populated to screen width, layout_height the same
Layout_width= "Wrap_content", automatically populated as control size, layout_height
LinearLayout, the layout used in the Android primer is LinearLayout, which is simple to understand: controls inside the linearlayout, arranged horizontally or vertically:
orientation= "Horizontal": horizontal arrangement; orientation= "vertical": vertical arrangement
When LinearLayout is horizontal, and the controls inside use layout_width= "Fill_parent", the second set of controls will block the right side of the screen, which is invisible.
Absolutelayout, a layout defined according to absolute coordinates, uses absolute coordinates to locate controls, so you should use absolutelayout sparingly when implementing an adaptive interface. The controls inside the Absolutelayout define their location in layout_x, layout_y:
The x coordinates of the TextView01 in the above figure are 10px,y coordinates 10px, and the page layout code is as follows:
<absolutelayout android:id= "@+id/absolutelayout01" android:layout_height= "Wrap_content" Fill_parent ">
<textview android:text=" TextView01 "android:id=" @+id/textview01 "android:layout_height=" Wrap_content "android:layout_y=" 10px "android:layout_width=" wrap_content "android:layout_x=" 110px ">
</ Textview>
</AbsoluteLayout>