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.