Android layout needs to know the basics

Source: Internet
Author: User

Eclipse Configuration Environment Variables:

1. Window in Eclipse------preferences Android (with ADT installed)--SDK location: Import SDK Path

2. Configure the Platform-tools, tools in the SDK directory to the Path of the environment variable

&& cmd command: adb (see if Android is configured for environment), Java (see if Java is configured for environment)

&& Configuring the Java environment variable: Configure the Bin directory in the JDK to an environment variable

Night-God Simulator Connection: (Prevent off-line)

Configure the Bin directory of the path where the night God Simulator is installed into the environment variable. CMD input command nox_adb connect 127.0.0.1:62001

  

Load the XML layout onto the Activity interface:

  Setcontentview (r.layout.mainactivity);

Basic properties common to all Android UI components and UI layout manager.

Drawabletop set the picture to the top of the text

Drawablebottom set the picture below the text

Drawableleft set the picture to the left of the text

Drawableright set the picture to the right of the text

Drawablepadding to set the spacing between pictures and text

Visibility is visible

Gravity setting the internal position of the component && equivalent to the padding

Gravity_layout setting the position of the component && equivalent margin

padding inner margin (distance within component)

Margin margin (distance outside the component)

  

Common Properties for TextView:

 Autolink setting text to a hyperlink

Lines set the number of lines of text

Ellipsize when content exceeds text, does not display the following content

Singleline setting a single line of text

typeface font format External import fonts

  

  

Relativelayout Common Properties for relative layouts:

  Align with parent form: 3+4 (property value is true or false)

Layout_centervertical Vertical Center

Layout_centerhorizontal Horizontal Center

Layout_centerinparent Parent Layout Center

    

Layout_alignparentleft the parent form left justified

Layout_alignparentright parent Form right-aligned

Layout_alignparenttop Alignment on parent form

Layout_alignbottom the parent form under alignment

  Alignment with other components: 4+4 (the attribute value must be the reference value of the ID, such as: you want to align with the component with ID btn: "@id/btn")

    Layout_toleftof on the left side of a component

Layout_toright on the right side of a component

Layout_above on top of a component

Layout_below at the bottom of a component

Layout_alignleft alignment relative to the left edge of a component

Layout_alignright Align relative to the right edge of a component

Layout_aligntop Alignment relative to the top edge of a component

Layout_alignbottom Alignment relative to the lower edge of a component

Label:

include   : Import another layout file into the current file (layout reuse). Format: <include layout= "@layout/xm_name" >

    Precautions:

1, <include/> Label can use the layout property alone, the introduction of layouts, is also a must attribute.

2. <include/> Tag will overwrite the label that introduces layout. The premise is to write Layout_width and laytout_height two properties.

3. The layout can contain two identical include tags.

merge : (no attribute layout) is used as the root layout. Reduce the level of layout (not more than 4 layers) when using include.  

   

viewstub: Dynamic loading

Table Layout tablelayout:

  Property: TableRow represents a row

Features: No need to write height and width, use weight (weight) to adjust.

&&: Weights are commonly used for linear layouts and table layouts.

Grid Layout (GridLayout)

Properties: ColumnCount setting Grid layout columns

  

Android layout needs to know the basics

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.