The window layout is implemented in the. xml file in layout.
Generally, you can use the eclipse code prompt function Alt +/to display the attribute values to be added later.
First, let's take a look at the linear layout: linearlayout
<? XML version = "1.0" encoding = "UTF-8"?> <Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" Android: Orientation = "vertical"> <! -- Window layout, which is vertical or horizontal --> <! -- Android: Id ~~~~~~~~~~~~~ Specify the corresponding ID for the control to access the Android: Text ~~~~~~~~~~~~~ Specify the text displayed in the control. Here, we try to use the string Android: grimace ~~~~~~~~~~~~~~~ defined in the string. xml file ~~~~~~~~~~~~~ Android: textsize ~~~~~~~~~~~~~ Specifies the font size of the Control. Android: Background ~~~~~~~~~~~~~ Specify the background color specified in the control. Use the RGB method Android: layout_width ~~~~~~~~~~~~~ Control width Android: layout_height ~~~~~~~~~~~~~ Control height Android: padding *~~~~~~~~~~~~~ Android: sigleline ~~~~~~~~~~~~~ If it is true, the content in the control is displayed in the same line. If it is not displayed, it will be used... represents --> <textview Android: Id = "@ + ID/firsttext" Android: text = "first line" Android: gravity = "center_vertical" Android: textsize = "18pt" Android: background = "# aa0000" Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" Android: paddingleft = "10dip" Android: paddingright = "30dip" Android: paddingtop = "20dip" Android: paddingbottom = "10dip" Android: layout_weight = "1" Android: singleline = "true"/> <textview Android: id = "@ + ID/secondtext" Android: text = "second line" Android: gravity = "center_vertical" Android: textsize = "18pt" Android: background = "#00aa00" Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" Android: paddingleft = "10dip" Android: paddingright = "30dip" Android: paddingtop = "20dip" Android: paddingbottom = "10dip" Android: layout_weight = "2" Android: singleline = "true"/> <button Android: id = "@ + ID/mybutton" Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" Android: layout_weight = "2"/> </linearlayout>
Let's take a look at the table layout: tablelayout
<? XML version = "1.0" encoding = "UTF-8"?> <Tablelayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" Android: stretchcolumns = "0"> <! -- Fill the screen by stretching the first column --> <! -- The first line --> <tablerow> <! -- Three columns are set in the first row --> <textview Android: text = "@ string/row1_column1" Android: Background = "# aa0000" Android: padding = "3dip"/> <textview Android: text = "@ string/row1_column2" Android: Background = "#00aa00" Android: padding = "3dip"/> <textview Android: TEXT = "@ string/row1_column3" Android: Background = "# tianaa" Android: padding = "3dip"/> </tablerow> <! -- Row 2 --> <tablerow> <! -- Two columns are set in the second row --> <textview Android: text = "@ string/row2_column1" Android: Background = "#00aa00" Android: padding = "3dip"/> <textview Android: text = "@ string/row2_column2" Android: Background = "# tianaa" Android: padding = "3dip"/> </tablerow> </tablelayout>