diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index 404413fe0..5abb7175f 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -28,7 +28,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at private var selectCharStart = 0 private var selectLineEnd = 0 private var selectCharEnd = 0 - private var textPage: TextPage = TextPage().textToLine() + private var textPage: TextPage = TextPage() //滚动参数 private val pageFactory: TextPageFactory get() = callBack.pageFactory private val maxScrollOffset = 100f @@ -49,11 +49,10 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { super.onSizeChanged(w, h, oldw, oldh) - ReadBookConfig.let { - ChapterProvider.viewWidth = w - ChapterProvider.viewHeight = h - ChapterProvider.upSize() - } + ChapterProvider.viewWidth = w + ChapterProvider.viewHeight = h + ChapterProvider.upSize() + textPage.format() } override fun onDraw(canvas: Canvas) { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt index c52a0834e..4e6089ddd 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt @@ -18,8 +18,8 @@ data class TextPage( ) { @Suppress("DEPRECATION") - fun textToLine(): TextPage { - if (textLines.isEmpty()) { + fun format(): TextPage { + if (textLines.isEmpty() && ChapterProvider.visibleWidth > 0) { val layout = StaticLayout( text, ChapterProvider.contentPaint, ChapterProvider.visibleWidth, Layout.Alignment.ALIGN_NORMAL, 1f, 0f, false