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 747f17497..c63ef5efe 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 @@ -19,27 +19,35 @@ import java.util.* class ContentView : FrameLayout { - + private var isScroll: Boolean = false private val bgImage: AppCompatImageView = AppCompatImageView(context) .apply { scaleType = ImageView.ScaleType.CENTER_CROP } - constructor(context: Context) : super(context) + constructor(context: Context) : super(context) { + this.isScroll = true + init() + } - constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) + constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) { + init() + } - constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super( - context, - attrs, - defStyleAttr - ) + constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : + super(context, attrs, defStyleAttr) { + init() + } - init { + fun init() { //设置背景防止切换背景时文字重叠 setBackgroundColor(context.getCompatColor(R.color.background)) addView(bgImage, LayoutParams(matchParent, matchParent)) - inflate(context, R.layout.view_book_page, this) + if (isScroll) { + inflate(context, R.layout.view_book_page_scroll, this) + } else { + inflate(context, R.layout.view_book_page, this) + } top_bar.layoutParams.height = context.getStatusBarHeight() upStyle() upTime() diff --git a/app/src/main/java/io/legado/app/ui/widget/page/PageScrollView.kt b/app/src/main/java/io/legado/app/ui/widget/page/PageScrollView.kt new file mode 100644 index 000000000..4ba6abb9b --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/widget/page/PageScrollView.kt @@ -0,0 +1,20 @@ +package io.legado.app.ui.widget.page + +import android.content.Context +import android.util.AttributeSet +import android.widget.ScrollView + + +class PageScrollView : ScrollView { + constructor(context: Context) : super(context) + + constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) + + constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) + + +} \ No newline at end of file diff --git a/app/src/main/res/layout/view_book_page_scroll.xml b/app/src/main/res/layout/view_book_page_scroll.xml new file mode 100644 index 000000000..edbdad825 --- /dev/null +++ b/app/src/main/res/layout/view_book_page_scroll.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file