Analysis of Android:gravity and android:layout_gravity

Source: Internet
Author: User

Android:gravity and android:layout_gravity These two properties believe that everyone usually use quite a lot of it. Have you ever thought about the difference between the two and different?

I believe some children's shoes are very clear, some children's shoes are smattering. Today we will look at the difference between the two, I hope that in the future to better help you to use both properties.

Android:gravity is actually more focused on the control itself, if set android:gravity= "center", which is meant to be centered within the content of the control.

Android:layout_gravity is actually more about the parent control or the layout nested in the outer layer, relative to the parent control rather than its own content. If you set android:layout_gravity= "Center_vertical|center_horizontal",

The intention is that the layout of the control is horizontally vertically centered relative to the outer layer.

I hope you will be able to use these two attributes clearly and accurately later.

Analysis of Android:gravity and android:layout_gravity

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.