Android Development--layout

Source: Internet
Author: User

One: LinearLayout

1, linear layout, this thing, from the outer frame can be understood as a Div, he first is a list from the top down on the screen. Each of the linearlayout can be divided into vertical layouts (android:orientation= "vertical") and horizontal layouts (android:orientation= "horizontal"). When vertical layout, there is only one element for each row, and multiple elements are descending vertically; when horizontal layout, there is only a row, and each element is arranged to the right.
There is an important attribute android:layout_weight= "1" in the LinearLayout, which represents the line spacing when vertical layout, the column width when horizontal, the larger the weight value.

2, TextView accounted for a certain space, there is no assignment is also a certain width, to pay special attention.

First Instance

   

     

Code:

<?xml version= "1.0" encoding= "Utf-8"?> <linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"android:orientation= "Vertical"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent" > <LinearLayout android:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"android:orientation= "Vertical" > <EditText android:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"/> </LinearLayout> <LinearLayout android:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"android:orientation= "Horizontal"android:gravity= "Right" > <!--android:gravity= "OK" means that the button component is aligned to starboard-<Button android:layout_height= "Wrap_content"Android:layout_width= "Wrap_content"Android:text= "OK"/> <Button android:layout_height= "Wrap_content"Android:layout_width= "Wrap_content"Android:text= "Cancel"/> </LinearLayout> </LinearLayout>

A second example:

       

Code:

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "Vertical" ><TextView android:layout_width= "Match_parent"Android:layout_height= "0DP"Android:layout_weight= "5"Android:background= "#3C3C3C"/><TextView android:layout_width= "Match_parent"Android:layout_height= "0DP"Android:layout_weight= "1"Android:background= "#FFEFD5"/> <LinearLayout android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:layout_weight= "4"Android:background= "#66CDAA"android:orientation= "Horizontal" > <TextView Android:id= "@+id/txt1"Android:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:background= "#FFF663"Android:layout_weight= "1"/> <TextView Android:id= "@+id/txt2"Android:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:background= "#E82917"Android:layout_weight= "4"/> <TextView Android:id= "@+id/txt3"Android:layout_width= "Wrap_content"Android:layout_height= "Match_parent"Android:background= "#FFF663"Android:layout_weight= "1"/> </LinearLayout></LinearLayout>

All we have to do is practice more and look at the layout of the software. The layout of the software and the layout of the real machine are different, we try to take the real machine to test, and on different models to go to test.

 

Android Development--layout

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.