From 5b8d4f9f6ac02ed3f80be8a9586a14c19b659533 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 20 Aug 2019 16:16:59 +0800 Subject: [PATCH] up --- .../java/io/legado/app/ui/widget/page/ContentView.kt | 11 ++++++++++- .../java/io/legado/app/ui/widget/page/PageView.kt | 10 +++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt b/app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt index e2bf5ba3f..7e26ae1dd 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt @@ -2,6 +2,7 @@ package io.legado.app.ui.widget.page import android.content.Context import android.graphics.Color +import android.graphics.drawable.Drawable import android.util.AttributeSet import android.widget.FrameLayout import io.legado.app.R @@ -26,7 +27,15 @@ class ContentView : FrameLayout { fun upStyle() { page_panel.horizontalPadding = 16.dp - page_panel.setBackgroundResource(R.drawable.bg1) + + } + + fun setBg(bg: Drawable?) { + page_panel.background = bg + } + + fun setBgColor(color: Int) { + page_panel.setBackgroundColor(color) } fun upTime() { diff --git a/app/src/main/java/io/legado/app/ui/widget/page/PageView.kt b/app/src/main/java/io/legado/app/ui/widget/page/PageView.kt index 255068c07..bb8ba6cd1 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/page/PageView.kt @@ -7,6 +7,7 @@ import android.graphics.Color import android.util.AttributeSet import android.view.MotionEvent import android.widget.FrameLayout +import io.legado.app.R import io.legado.app.ui.widget.page.delegate.CoverPageDelegate import io.legado.app.ui.widget.page.delegate.PageDelegate import kotlinx.android.synthetic.main.view_book_page.view.* @@ -28,7 +29,7 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att addView(nextPage) curPage = ContentView(context) addView(curPage) - + upBg() setWillNotDraw(false) page_panel.backgroundColor = Color.WHITE @@ -111,6 +112,13 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att nextPage?.upStyle() } + fun upBg() { + val bg = context.getDrawable(R.drawable.bg1) + curPage?.setBg(bg) + prevPage?.setBg(bg) + nextPage?.setBg(bg) + } + fun upTime() { curPage?.upTime() prevPage?.upTime()