Android Application Software Development (6) window layout

Source: Internet
Author: User

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>
Related Article

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.