0

What is the best way to justify TextView (with LTR and RTL) in Kotlin?

I tried many libraries like:

implementation 'com.codesgood:justifiedtextview:1.1.0'

implementation 'me.biubiubiu.justifytext:library:1.1'

implementation 'com.github.bluejamesbond:textjustify-android:2.1.6'

implementation 'com.github.pouriaHemmati:JustifiedTextView:1.0.0'

But they are not a perfect solution.

  • We cannot help you if you do not explain in detail what problems you encountered with the existing solutions, both in terms of your cited libraries and in terms of [this SO question](https://stackoverflow.com/q/1292575/115145) and [this SO question](https://stackoverflow.com/q/21178571/115145). – CommonsWare Jan 11 '23 at 20:56
  • Does this https://stackoverflow.com/questions/1292575/android-textview-justify-text/42991773 answer your question? – DmitryArc Jan 11 '23 at 21:41

1 Answers1

0

In Kotlin, the best way to justify text in a TextView would be to use the gravity property in conjunction with the textAlignment property.

val textView = findViewById<TextView>(R.id.text_view)
textView.gravity = Gravity.END
textView.textAlignment = View.TEXT_ALIGNMENT_VIEW_END
Cris
  • 131
  • 6