sherry sherry - 1 month ago 8
Android Question

How to right-align text in an Android TextView or EditText?

I have an EditText in my application. I want to align the text in it to the right instead of the default left. I tried adding

android:layout_gravity="right"


but this doesn't seem to work. any other suggestions please?

Answer

You should use android:gravity="right". layout_gravity is for the view (EditText) alignment against the container.