Method for realizing button centering in Android

This article describes the method of button centering in Android. Share with you for your reference. The details are as follows:

When arranging buttons in main.xml or other XML layout files, select Android: gravity = "center_horizontal", which means place object in the horizontal center of its container, not changing its size.

main.xml:

Screenshot of operation effect:

Brief description:

You can see that the button is aligned with the gallery in the center, that is, the button is aligned with the parent in the center. In addition, Android: gravity = "center_vertical": This is vertically centered. Android: gravity = "bottom": it is placed at the bottom of the container. Android: gravity = "center": it is placed at the center of the container

I hope this article will be helpful to your Android program design.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>