Shorter code here because I'm looking at it

Change-Id: I444d0fa28fc92f996d58c16f65d9bebbd065ef69
This commit is contained in:
SpiritCroc 2020-09-05 17:48:38 +02:00
parent 2995375586
commit 3a47c1b438
1 changed files with 2 additions and 3 deletions

View File

@ -9,6 +9,7 @@ import android.text.Layout
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView
import kotlin.math.ceil
import kotlin.math.max
class WrapWidthTextView @JvmOverloads constructor(
context: Context,
@ -28,9 +29,7 @@ class WrapWidthTextView @JvmOverloads constructor(
var maxWidth = 0.0f
val lines = layout.lineCount
for (i in 0 until lines) {
if (layout.getLineWidth(i) > maxWidth) {
maxWidth = layout.getLineWidth(i)
}
maxWidth = max(maxWidth, layout.getLineWidth(i))
}
return maxWidth
}