Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add gravity to EditText programmatically

I try add CENTER_VERTICAL to EditText:

((EditText)childView).setGravity( ((EditText)childView).getGravity() | Gravity.CENTER_VERTICAL);

I need ADD (but NOT CHANGE !!!) any another current gravity of View.

Example, EditText already have gravity LEFT. I try

((EditText)childView).setGravity( Gravity.CENTER_VERTICAL);

but new gravity is kill LEFT gravity.

What is best way to ADD new gravity?

like image 829
Tapa Save Avatar asked May 20 '26 23:05

Tapa Save


1 Answers

Try:

((EditText)childView).setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);

You must be knowing the initial gravity set.

like image 145
Archie.bpgc Avatar answered May 23 '26 12:05

Archie.bpgc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!