Summary of XML layout content (ii)--android

Source: Internet
Author: User

About the content of the margin and padding in XML, there will be some confusion and ambiguity in the first contact with XML, in this summary, hope to help people in need.

2.xml in margin and padding

<?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:layout_margin= "10DP"//When the margins in the upper and lower left and right four directions are consistent, this unified setting can be used
android:background= "@color/red"
android:orientation= "Vertical" >


<linearlayout
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:background= "@color/yellow"
android:layout_marginleft= "5DP"//can be set separately when the margin is inconsistent between the top and left four directions
android:layout_margintop= "15DP"
android:layout_marginright= "25DP"
Android:layout_marginbottom= "35DP"
android:orientation= "Vertical" >


<linearlayout
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"

android:layout_margin= "15DP"//This is an outer border

android:padding= "35DP"//This is the inner border, the inner border of the four in the same direction, you can set the unified
android:background= "@color/blue"
android:orientation= "Vertical" >
<linearlayout
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:background= "@color/gray"
android:paddingleft= "5DP"//inner border is inconsistent in four directions, can be set separately
android:paddingtop= "15DP"
android:paddingright= "25DP"
Android:paddingbottom= "35DP"
android:orientation= "Vertical" >

<linearlayout
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:background= "@color/green"
android:orientation= "Vertical" >

</LinearLayout>

</LinearLayout>

</LinearLayout>

</LinearLayout>

</LinearLayout>


As follows:


The adoption and the settings in the XML should soon be able to grasp the use of margin and padding


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Summary of XML layout content (ii)--android

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.