From df38b79abe8e80642988124a28634cc36b00fafb Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 11:03:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/read/page/ChapterProvider.kt | 10 ++++++++-- app/src/main/res/layout/dialog_title_config.xml | 2 ++ app/src/main/res/layout/view_book_page.xml | 12 ++++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 3366c019d..927ef210f 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -28,6 +28,8 @@ object ChapterProvider { var visibleBottom = 0 private var lineSpacingExtra = 0 private var paragraphSpacing = 0 + private var titleTopSpacing = 0 + private var titleBottomSpacing = 0 var typeface: Typeface = Typeface.SANS_SERIF var titlePaint = TextPaint() var contentPaint = TextPaint() @@ -97,7 +99,7 @@ object ChapterProvider { stringBuilder: StringBuilder, isTitle: Boolean ): Float { - var durY = y + var durY = if (isTitle) y + titleTopSpacing else y val textPaint = if (isTitle) titlePaint else contentPaint val layout = StaticLayout( text, textPaint, visibleWidth, @@ -140,6 +142,9 @@ object ChapterProvider { textPages.last().textLines.add(textLine) textLine.upTopBottom(durY, textPaint) durY += textPaint.textHeight * lineSpacingExtra / 10f + if (isTitle) { + durY += titleBottomSpacing + } textPages.last().height = durY } durY += textPaint.textHeight * paragraphSpacing / 10f @@ -273,7 +278,8 @@ object ChapterProvider { paragraphSpacing = ReadBookConfig.paragraphSpacing titlePaint.textSize = (ReadBookConfig.textSize + 2).sp.toFloat() contentPaint.textSize = ReadBookConfig.textSize.sp.toFloat() - + titleTopSpacing = ReadBookConfig.titleTopSpacing.dp + titleBottomSpacing = ReadBookConfig.titleBottomSpacing.dp upSize() } diff --git a/app/src/main/res/layout/dialog_title_config.xml b/app/src/main/res/layout/dialog_title_config.xml index 4a2d35cd8..93e14f89c 100644 --- a/app/src/main/res/layout/dialog_title_config.xml +++ b/app/src/main/res/layout/dialog_title_config.xml @@ -39,6 +39,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="3dp" + app:max="100" app:title="上间距" /> \ No newline at end of file diff --git a/app/src/main/res/layout/view_book_page.xml b/app/src/main/res/layout/view_book_page.xml index 81c9e09d4..bba89c8fb 100644 --- a/app/src/main/res/layout/view_book_page.xml +++ b/app/src/main/res/layout/view_book_page.xml @@ -16,12 +16,14 @@ android:id="@+id/tv_top_left" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_weight="1" /> + android:layout_weight="1" + android:textSize="12sp" /> + android:layout_height="wrap_content" + android:textSize="12sp" /> @@ -56,12 +58,14 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" - android:singleLine="true" /> + android:singleLine="true" + android:textSize="12sp" /> + android:layout_height="wrap_content" + android:textSize="12sp" />