Skip to content

Commit

Permalink
[add][#61] Justify text option
Browse files Browse the repository at this point in the history
  • Loading branch information
jeziellago committed Nov 29, 2023
1 parent ff47ec1 commit 5278317
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dev.jeziellago.compose.markdowntext

import android.content.Context
import android.graphics.Paint
import android.graphics.text.LineBreaker
import android.os.Build
import android.text.SpannableStringBuilder
import android.text.Spanned
Expand Down Expand Up @@ -187,6 +188,10 @@ private fun createTextView(
typeface = ResourcesCompat.getFont(context, font)
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && textAlign == TextAlign.Justify) {
justificationMode = LineBreaker.JUSTIFICATION_MODE_INTER_WORD
}

if (truncateOnTextOverflow) {
doOnNextLayout {
if (maxLines != -1 && lineCount > maxLines) {
Expand Down

0 comments on commit 5278317

Please sign in to comment.