capcom capcom - 6 months ago 26
Android Question

Android: Center text inside EditText programatically

As the title says, is there any way to center the inputted text in an

EditText
field. More specifically, instead of the cursor starting at the left of the box, it should start in the center and move outward towards the left as it is populated with inputs.

Thanks.

A.A A.A
Answer

you should use

 textView.setGravity(Gravity.CENTER_HORIZONTAL);