0

I have an old Android project which has used the textAlignment property for years to center text in a TextView. It has just been brought to my attention that this no longer works, and the text now display as left aligned.

I can fix this with the gravity property, but is this a known change??? I am concerned there might be other changes that need to be addressed, that I am not aware of.

FYI - I'm targeting 29.

eimmer
  • 1,537
  • 1
  • 10
  • 29
  • You will need to supply a little more information such as API level for which it works (or doesn't) and maybe some XML. In the meantime, this [Stack Overflow question](https://stackoverflow.com/q/16196444/6287910) and its answers may provide you with some useful information. – Cheticamp Jan 27 '21 at 21:51
  • How does this affect whether or not it is a *known* change? – eimmer Jan 27 '21 at 22:05
  • 1
    @eimmer it's not known to change. He provided you a link where you can seek your answer. It says there that you should prefer gravity over textAlignment for few reasons. Check it out and it will probably answer your question. But since we don't have your XML we can't say that anything else is affecting textAlignment in your XML. – SlothCoding Jan 28 '21 at 00:17

2 Answers2

0

you should check android:supportsRtl="true"

if it still not work,check tools:replace="android:supportsRtl"

戴文锦
  • 1,985
  • 1
  • 7
  • 5
0

Change your TextView with this one and use textalignment=center

<androidx.appcompat.widget.AppCompatTextView
     android:textAlignment="center" />