Text controls
-TextView
-EditText
Button controls
-Button
-ImageButton
Status Switch button
-ToggleButton
Radio and Check buttons
-CheckBox
-RadioButton
Picture controls
-ImageView
Clock control
-AnalogClock
-DigitalClock
Date and time selection controls
-Datapicker
-Timepicker
Layout file:
LinearLayout and Relativelayout
Common attributes:
Associating secondary controls with BTN1 in Java code
Android:id= "@+id/btn1″
Control width
Android:layout_width= "80px"//"80dip" or "80DP"
Android:layout_width = "Wrap_content"
Android:layout_width = "Match_parent"
Control height
android:layout_height= "80px"//"80dip" or "80DP"
Android:layout_height = "Wrap_content"
Android:layout_height = "Match_parent"
Control arrangement
android:orientation= "Horizontal"
android:orientation= "Vertical"
Control spacing
android:layout_marginleft= "5dip"//distance to the left
android:layout_marginright= "5dip"//distance to the right
android:layout_margintop= "5dip"//Distance above
android:layout_marginright= "5dip"//Distance below
Control Display Location
android:gravity= "center"//left,right, top, bottom
Android:gravity= "Center_horizontal"
Android:layout_gravity is the gravity direction of this element to the parent element.
The Android:layout_gravity property sets the display position of the control itself relative to the parent control
Android:gravity is the gravity direction of all child elements of this element.
Android:layout_gravity= "Center_vertical"
Android:layout_gravity= "left"
Android:layout_gravity= "Left|bottom"
TextView Chinese text font
android:text= "@String/text1″//defines the value of Text1 in String.xml
Android:textsize= "20SP"
Android:textcolor= "#ff123456"
Android:textstyle= "bold"//Normal (normal), italic (italic), coarse italic (bold_italic)
Defines whether the control is visible
android:visibility= "visible"//Visible
android:visibility= "Invisible"//is not visible, but the position occupied in the layout is still
Android:visibility= "Gone"//not visible, completely disappearing from layout
Define a background picture
android:background= "@drawable/img_bg"//IMG_BG is a picture under drawable
Seekbar control background picture and maximum value
android:progressdrawable= "@drawable/seekbar_img"
android:thumb= "@drawable/thumb"
Android:max = "60″
Valid only in Relativelayout:
In the relative position of the father's layout
Android:layout_alignparentleft= "true"//on the left side of the layout
Android:layout_alignparentright= "true"//on the right side of the layout
Android:layout_alignparenttop= "true"//above the layout
Android:layout_alignparentbottom= "true"//below the layout
In the relative position of a control
android:layout_torightof= "@id/button1″//on the right side of the control button1, not just close to the
android:layout_toleftof= "@id/button1″//on the left side of the control button2, not just close to the
android:layout_below= "@id/button1"//under control Button1, not just directly below
Android:layout_above= "@id/button1"//under control Button1, not just directly below
Definition and a control pair of odd
android:layout_aligntop= "@id/button1"//and alignment on controls button1
android:layout_alignbottom= "@id/button1"//and controls button1 aligned
android:layout_alignleft= "@id/button1"//and control Button1 left justified
android:layout_alignright= "@id/button1"//and control button2 right align
Android:layout_centerhorizontal= "true"//Horizontal Center
Android:layout_centervertical= "true"
Android:layout_centerinparent= "true"
Valid only in LinearLayout
To set a control's proportional value in a row or column
Android:layout_weight= "1″
Basic UI controls and layout file Knowledge Essentials (Android)