Android Button or TextView Vertical Alignment

I am trying to vertically align a button or text image, but I cannot. Neither android:layout_gravity="center_vertical|center_horizontal" nor android:gravity="center_vertical|center_horizontal" does not work. Not even android:gravity="center" does the trick. They only align the object horizontally. How can I align it to the center or bottom of the view?

+4
source share
1 answer

Depends on the parent layout. If you use RelativeLayout, you can just use layout_alignParentBottom="true" , although layout_gravity="bottom" should work. Keep in mind the size of this parent layout. You cannot use alignParentBottom if RelativeLayout is set to wrap_content for height. It must be set to fill_parent . You should publish the rest of your XML if you still have problems.

+1
source

Source: https://habr.com/ru/post/1336615/


All Articles