pull/34/head
kunfei 5 years ago
parent ce629e0dc3
commit 1966ef6079
  1. 28
      app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt
  2. 20
      app/src/main/java/io/legado/app/ui/widget/page/PageScrollView.kt
  3. 65
      app/src/main/res/layout/view_book_page_scroll.xml

@ -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()

@ -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
)
}

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/page_panel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:divider="@drawable/ic_divider"
app:showDividers="middle">
<LinearLayout
android:id="@+id/top_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_top_left"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/tv_top_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<io.legado.app.ui.widget.page.PageScrollView
android:id="@+id/page_scroll_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbars="none">
<io.legado.app.ui.widget.page.ContentTextView
android:id="@+id/content_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</io.legado.app.ui.widget.page.PageScrollView>
<LinearLayout
android:id="@+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_bottom_left"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true" />
<TextView
android:id="@+id/tv_bottom_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
Loading…
Cancel
Save