Android Tips: A summary of Android XML layouts

Source: Internet
Author: User

I. BACKGROUND

Maybe a lot of people like me, have done a long time Android program, but have not seriously sit down and learn the layout of the XML file. In fact, sometimes we use the view to draw or use the ADT graphical interface features can easily handle the layout, but it is best to calm down to learn the layout of XML in the specific wording. In this section we will draw the interface shown in the following figure.

Two basic knowledge

First we want to know what Android has in the end, and what the difference is between each type of layout.

1. Linear Layout LinearLayout

The linear layout is divided into two kinds. One is horizontal layout, one is vertical layout. Let's follow the example above.

Just post the code above.

<?xml version= "1.0" encoding= "Utf-8"?> <linearlayout android:orientation= "vertical"  
    Fill_parent "android:layout_height=" fill_parent "xmlns:android=" http://schemas.android.com/apk/res/android "> <textview android:layout_height= "wrap_content" android:text= "@string/note_title" android:layout_width= "Wrap_co Ntent "android:padding=" 10DP "></TextView> <linearlayout android:layout_height=" Fill_parent "Andr Oid:layout_width= "Fill_parent" android:layout_weight= "1" > <edittext android:id= "@+id/edittext02" android:l Ayout_width= "Fill_parent" android:layout_height= "fill_parent" android:gravity= "left" android:hint= "@string/edithint" ></EditText> </LinearLayout> <linearlayout android:layout_height= "Fill_par Ent "android:layout_width=" fill_parent "android:layout_weight=" 2 "android:gravity=" center "<p class=" P1 " > AndroId:orientation<span class= "S1" >=</span><span class= "s2" > "Horizontal" </span></p> > <imagebutton android:id= "@+id/imagebutton01" android:layout_width= "72DP" Android:layout_h  
        eight= "72DP" android:src= "@drawable/sketchy_paper_003" android:layout_margin= "3DP" ></ImageButton> <imagebutton android:id= "@+id/imagebutton02" android:layout_width= "72DP" android:layout_height= "72DP "Android:src=" @drawable/sketchy_paper_004 "android:layout_margin=" 3DP "></ImageButton> <
            ImageButton android:id= "@+id/imagebutton03" android:layout_width= "72DP" android:layout_height= "72DP"  android:src= "@drawable/sketchy_paper_007" android:layout_margin= "3DP" ></ImageButton> <imagebutton Android:id= "@+id/imagebutton04" android:layout_width= "72DP" android:layout_height= "72DP" Android: src= "@drawable/sketchy_paper_011 "android:layout_margin=" 3DP "></ImageButton> </LinearLayout> </LinearLayout> 

As you can see, the figure above is made up of three parts. In the large linearlayout from top to bottom distributes three contents vertically: Textview,linearlayout,linearlayout. So the overall linearlayout is the vertical layout

android:orientation= "Vertical"

Now let's look at the horizontal layout

In fact, the linearlayout is the bottom of the picture above. The four icons are arranged in parallel.

android:orientation= "Horizontal"

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/

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.