Differences between Android: gravity and Android: layout_gravity Android: padding and Android: layout_margin

Source: Internet
Author: User

I. Differences between Android: gravity and Android: layout_gravity

Android; gravity is the position of its content relative to its own control, while Android: layout_gravity is its position relative to its parent class.

For example, if there is an edittext file, one sets Android: gravity = "center" to center the text in edittext in the edittext component. At the same time, we set the android of edittext: layout_gravity = "right" to center the edittext component in linearlayout. As shown in:

Ii. Differences between Android: padding and Android: layout_margin

Padding is standingParent ViewIt specifies the distance between the content and the parent view. Margin stands onYourselfIt specifies the distance between yourself and other views (up and down). If there is only one view at the same level, the effect is basically the same as that of padding.

 

 

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.