What is the best way to justify TextView in Kotlin?

163 Views Asked by At

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.

1

There are 1 best solutions below

1
Cris On

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