Android layouts and Intent notes and common examples

Source: Internet
Author: User

Getting to know and familiar with Android top apps today, repent-_-| |

Three common layout methods: LinearLayout (Linear layout), tablelayout (table layout), relative Layout (relative layout).

The relative layout is more casual than the previous two layout methods, where users can place controls anywhere they want.

Common directives in linearlayout and Tablelayout are

android:id--control to specify the appropriate ID

The text is displayed in the android:text--control. Be careful to use strings.xml as much as possible

android:gravity--the basic position of text in a control, such as center, left, right, center_horizontal, and so on.

The font size in the android:textsize--control, in units of Pt.

android:background--Control Background Color

android:width--Control width

android:height--Control Height

android:padding--space within the margin, the charge of the contents of the piece to space distance. Among them are android:padding_left, android:padding_right and so on.

android:siglelise--if set to true, the content of the control will be displayed on the same line.

android:margin--the outer margin.

Relative layout relative Layout

android:layout_above--the control to the bottom of the given control

android:layout_below--the top of the control to the given control

android:layout_toleftof--the left edge of the control to the right of the given control

android:layout_torightof--the left edge of the control to the right of the given control

android:layout_alignbaseline--aligns the control's baseline with the baseline of the specified control.

android:layout_alignleft--aligns the left side of the control with the left edge of the specified control.

android:layout_alignright--aligns the right side of the control to the right of the specified control.

android:layout_aligntop--aligns the top of the control with the top of the specified control.

android:layout_alignparentbottom--is true, the control is aligned with the parent control.

android:layout_centerhorizontal--is true and space is centered in the horizontal direction.

android:layout_centerinparent--is true, as to the center of the parent control horizontally/vertically.

The android:layout_centervertural--is placed vertically in the center.

Intent-filter

1 Android.intent.action.MAIN determines which activity the application starts first.

2 Android.intent.category.LAUNCHER Determines whether the application is displayed in the list of programs.

Intent Invoke Application

Example: Call Google browser

Uri uri = uri.parse ("http://www.android123.com.cn");

Intent it = new Intent (Intent.action_view,uri);

StartActivity (IT);

Commonly used application calls

Show Web pages:

1. Uri uri = uri.parse ("http://www.android123.com.cn");

2. Intent it = new Intent (Intent.action_view,uri);

3. StartActivity (it);

Show Google Maps:

1. Uri uri = uri.parse ("geo:38.899533,-77.036476");

2. Intent it = new Intent (Intent.action_view,uri);

3. StartActivity (it);

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.