开发者

Android button or TextView vertical align

开发者 https://www.devze.com 2023-02-05 23:37 出处:网络
i am trying to vertically align a button or a textview, but i can\'t. Neither android:layout_gravity=\"center_vertical|cen开发者_高级运维ter_horizontal\" nor android:gravity=\"center_vertical|center_h

i am trying to vertically align a button or a textview, but i can't. Neither android:layout_gravity="center_vertical|cen开发者_高级运维ter_horizontal" nor android:gravity="center_vertical|center_horizontal" works. Not even android:gravity="center" does the trick. They only aligns the object horizontally. How can i align it to the center or bottom of the view?


Depends on the parent layout. If you're using a RelativeLayout, you can simply use layout_alignParentBottom="true", although layout_gravity="bottom" should work as well. Keep in mind the size of this parent layout as well. You can't use alignParentBottom if the RelativeLayout is set to wrap_content for height. It should be set to fill_parent. You should post the rest of your XML if you're still having issues.

0

精彩评论

暂无评论...
验证码 换一张
取 消