forked from upstream-mirrors/quik
Correctly wrap width for message body TextView
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package com.moez.QKSMS.presentation.view
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.widget.TextView
|
||||
|
||||
class TightTextView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyle: Int = 0)
|
||||
: TextView(context, attrs, defStyle) {
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||
|
||||
layout?.let {
|
||||
val maxLineWidth = (0 until layout.lineCount)
|
||||
.asSequence()
|
||||
.map { layout.getLineMax(it) }
|
||||
.max() ?: 0f
|
||||
|
||||
val width = (Math.ceil(maxLineWidth.toDouble()).toInt() + compoundPaddingLeft + compoundPaddingRight)
|
||||
val height = measuredHeight
|
||||
setMeasuredDimension(width, height)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,7 +38,7 @@
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
<com.moez.QKSMS.presentation.view.TightTextView
|
||||
android:id="@+id/body"
|
||||
style="@style/TextPrimary"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
<com.moez.QKSMS.presentation.view.TightTextView
|
||||
android:id="@+id/body"
|
||||
style="@style/TextPrimary"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
Reference in New Issue
Block a user