Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Set two Gravity parameters programmatically

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.

like image 640
Paulius Vindzigelskis Avatar asked Apr 27 '12 12:04

Paulius Vindzigelskis


3 Answers

In case you are wondering the Kotlin version it is

your_button.gravity = Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL

like image 172
Alessandro Mautone Avatar answered Nov 16 '22 06:11

Alessandro Mautone


Try

setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
like image 41
EvilDuck Avatar answered Nov 16 '22 06:11

EvilDuck


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)

like image 33
Dinesh Avatar answered Nov 16 '22 06:11

Dinesh