feat: 优化代码

pull/141/head
kunfei 5 years ago
parent 657f9181bf
commit f4fe3206f7
  1. 27
      app/src/main/java/io/legado/app/ui/widget/text/MultilineTextView.kt
  2. 2
      app/src/main/res/layout/item_search.xml

@ -0,0 +1,27 @@
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) {
private var calculatedLines = false
override fun onDraw(canvas: Canvas?) {
if (!calculatedLines) {
calculateLines();
calculatedLines = true;
}
super.onDraw(canvas)
}
private fun calculateLines() {
val mHeight = measuredHeight
val lHeight = lineHeight
val lines = mHeight / lHeight
setLines(lines)
}
}

@ -75,7 +75,7 @@
android:textColor="@color/tv_text_default"
android:textSize="12sp" />
<TextView
<io.legado.app.ui.widget.text.MultilineTextView
android:id="@+id/tv_introduce"
android:layout_width="match_parent"
android:layout_height="match_parent"

Loading…
Cancel
Save