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 c4d25197d..ad8b706ac 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 @@ -14,7 +14,10 @@ import io.legado.app.help.AppConfig import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadTipConfig import io.legado.app.ui.book.read.page.entities.TextPage -import io.legado.app.utils.* +import io.legado.app.utils.dp +import io.legado.app.utils.getCompatColor +import io.legado.app.utils.statusBarHeight +import io.legado.app.utils.visible import kotlinx.android.synthetic.main.view_book_page.view.* import java.util.* @@ -23,6 +26,9 @@ class ContentView(context: Context) : FrameLayout(context) { private var battery = 100 + val headerHeight: Int + get() = if (ReadBookConfig.hideStatusBar) ll_header.height else context.statusBarHeight + init { //设置背景防止切换背景时文字重叠 setBackgroundColor(context.getCompatColor(R.color.background)) @@ -49,19 +55,14 @@ class ContentView(context: Context) : FrameLayout(context) { tv_footer_middle.setColor(durConfig.textColor()) tv_footer_right.setColor(durConfig.textColor()) //显示状态栏时隐藏header - if (hideStatusBar) { - ll_header.setPadding( - headerPaddingLeft.dp, - headerPaddingTop.dp, - headerPaddingRight.dp, - headerPaddingBottom.dp - ) - ll_header.visible() - page_panel.setPadding(0, 0, 0, 0) - } else { - ll_header.gone() - page_panel.setPadding(0, context.statusBarHeight, 0, 0) - } + vw_status_bar.setPadding(0, context.statusBarHeight, 0, 0) + vw_status_bar.isGone = hideStatusBar + ll_header.setPadding( + headerPaddingLeft.dp, + headerPaddingTop.dp, + headerPaddingRight.dp, + headerPaddingBottom.dp + ) ll_footer.setPadding( footerPaddingLeft.dp, footerPaddingTop.dp, @@ -90,18 +91,11 @@ class ContentView(context: Context) : FrameLayout(context) { tv_footer_left.isInvisible = tipFooterLeftNone tv_footer_right.isGone = tipFooterRightNone tv_footer_middle.isGone = tipFooterMiddleNone + ll_header.isGone = hideHeader + ll_footer.isGone = hideFooter } } - val headerHeight: Int - get() { - return if (ReadBookConfig.hideStatusBar) { - ll_header.height - } else { - context.statusBarHeight - } - } - fun setBg(bg: Drawable?) { page_panel.background = bg } diff --git a/app/src/main/res/layout/view_book_page.xml b/app/src/main/res/layout/view_book_page.xml index d936ec62d..c15680c91 100644 --- a/app/src/main/res/layout/view_book_page.xml +++ b/app/src/main/res/layout/view_book_page.xml @@ -6,6 +6,11 @@ android:layout_height="match_parent" android:orientation="vertical"> + +