Android: difference between setTextAlignment and setGravity

I'm working with EditText

and know it was setTextAlignment

n't implemented until API 17 , but I don't see any setTextAlignment

easier or better use than setGravity

. What should I use for what purpose, or does it not matter?

I find it setGravity

very easy to work and do what I want, so when should I NOT be using this?

thank

+3


source to share


2 answers


setTextAlignment

available from API level 17, you won't be able to use it until 17. But setGravity

, available at API level 1. You can use it anywhere.

setGravity



Sets the horizontal text alignment and vertical gravity to be used when the TextView has extra space outside of what is required for the text itself

+1


source


setTextAlignment()

it's easier to work with right-handed locales: you can align to the language beginning text or text without having to know if it's left or right.



textAlignment

will not work. For many alignment modes, you need to actually combine it with gravity.

+1


source







All Articles