I have button and want to change its text gravity to bottom center. How can I do that programmatically?
I can only find that I can change to center OR bottom, not both.
In case you are wondering the Kotlin version it is
your_button.gravity = Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL
Try
setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
Try this code:
your_button.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
for more details below link
http://developer.android.com/reference/android/widget/TextView.html#setGravity(int)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With