mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
7d552cc3eb
commit
9b49200a85
@ -1,22 +1,21 @@
|
||||
package io.legado.app.ui.widget.text
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
import android.util.AttributeSet
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
|
||||
class MultilineTextView(context: Context, attrs: AttributeSet?) :
|
||||
AppCompatTextView(context, attrs) {
|
||||
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
calculateLines()
|
||||
super.onDraw(canvas)
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
val heightSize = MeasureSpec.getSize(heightMeasureSpec)
|
||||
calculateLines(heightSize)
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||
}
|
||||
|
||||
private fun calculateLines() {
|
||||
val mHeight = measuredHeight
|
||||
private fun calculateLines(measuredHeight: Int) {
|
||||
val lHeight = lineHeight
|
||||
val lines = mHeight / lHeight
|
||||
val lines = measuredHeight / lHeight
|
||||
setLines(lines)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user