From 2e2f27b9ca097777a849ac1bd03b1cf13d940624 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 19 Feb 2020 21:14:29 +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 --- .../app/ui/book/read/page/ContentView.kt | 31 +++++++++++++++---- app/src/main/res/layout/view_book_page.xml | 4 +-- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt index 70bdc120e..78ed08216 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt @@ -36,7 +36,6 @@ class ContentView : FrameLayout { //设置背景防止切换背景时文字重叠 setBackgroundColor(context.getCompatColor(R.color.background)) inflate(context, R.layout.view_book_page, this) - top_bar.layoutParams.height = context.getStatusBarHeight() upStyle() upTime() content_text_view.customSelectionActionModeCallback = @@ -53,15 +52,35 @@ class ContentView : FrameLayout { fun upStyle() { ReadBookConfig.getConfig().apply { - val pt = if (context.getPrefBoolean(PreferKey.hideStatusBar, false)) { - top_bar.visible() + val rootPaddingTop = if (context.getPrefBoolean(PreferKey.hideStatusBar, false)) { + //显示状态栏时隐藏header + ll_header.visible() + ll_header.layoutParams = + ll_header.layoutParams.apply { height = context.getStatusBarHeight() } + ll_header.setPadding( + headerPaddingLeft, + headerPaddingTop, + headerPaddingRight, + headerPaddingBottom + ) 0 } else { - top_bar.gone() + ll_header.gone() context.getStatusBarHeight() } - page_panel.setPadding(paddingLeft.dp, pt, paddingRight.dp, 0) - content_text_view.setPadding(0, paddingTop.dp, 0, paddingBottom.dp) + page_panel.setPadding(0.dp, rootPaddingTop, 0, 0) + content_text_view.setPadding( + paddingLeft.dp, + paddingTop.dp, + paddingRight.dp, + paddingBottom.dp + ) + ll_footer.setPadding( + footerPaddingLeft.dp, + footerPaddingTop.dp, + footerPaddingRight.dp, + footerPaddingBottom.dp + ) content_text_view.textSize = textSize.toFloat() content_text_view.setLineSpacing(lineSpacingExtra.toFloat(), lineSpacingMultiplier) content_text_view.letterSpacing = letterSpacing diff --git a/app/src/main/res/layout/view_book_page.xml b/app/src/main/res/layout/view_book_page.xml index dc08099fa..81c9e09d4 100644 --- a/app/src/main/res/layout/view_book_page.xml +++ b/app/src/main/res/layout/view_book_page.xml @@ -6,7 +6,7 @@ android:orientation="vertical">