优化页眉页脚
This commit is contained in:
@@ -2,6 +2,7 @@ package io.legado.app.ui.book.read.page
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.Typeface
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.FrameLayout
|
||||
@@ -191,6 +192,7 @@ class PageView(context: Context) : FrameLayout(context) {
|
||||
}
|
||||
tvTitleArrow = getTipView(ReadTipConfig.chapterTitleArrow)?.apply {
|
||||
tag = ReadTipConfig.chapterTitleArrow
|
||||
typeface = Typeface.DEFAULT
|
||||
textSize = 12f
|
||||
batteryMode = BatteryView.BatteryMode.ARROW
|
||||
}
|
||||
@@ -208,6 +210,7 @@ class PageView(context: Context) : FrameLayout(context) {
|
||||
}
|
||||
tvBattery = getTipView(ReadTipConfig.battery)?.apply {
|
||||
tag = ReadTipConfig.battery
|
||||
typeface = Typeface.DEFAULT
|
||||
textSize = 11f
|
||||
batteryMode = BatteryView.BatteryMode.OUTER
|
||||
}
|
||||
@@ -218,11 +221,13 @@ class PageView(context: Context) : FrameLayout(context) {
|
||||
}
|
||||
tvBatteryInside = getTipView(ReadTipConfig.batteryInside)?.apply {
|
||||
tag = ReadTipConfig.batteryInside
|
||||
typeface = Typeface.DEFAULT
|
||||
textSize = 11f
|
||||
batteryMode = BatteryView.BatteryMode.INNER
|
||||
}
|
||||
tvBatteryIcon = getTipView(ReadTipConfig.batteryIcon)?.apply {
|
||||
tag = ReadTipConfig.batteryIcon
|
||||
typeface = Typeface.DEFAULT
|
||||
textSize = 11f
|
||||
batteryMode = BatteryView.BatteryMode.ICON
|
||||
}
|
||||
@@ -258,6 +263,7 @@ class PageView(context: Context) : FrameLayout(context) {
|
||||
}
|
||||
tvTimeBattery = getTipView(ReadTipConfig.timeBattery)?.apply {
|
||||
tag = ReadTipConfig.timeBattery
|
||||
typeface = Typeface.DEFAULT
|
||||
textSize = 11f
|
||||
batteryMode = BatteryView.BatteryMode.TIME
|
||||
}
|
||||
|
||||
@@ -21,10 +21,6 @@ class BatteryView @JvmOverloads constructor(
|
||||
|
||||
enum class BatteryMode { OUTER, INNER, ICON, ARROW, TIME, CLASSIC, NO_BATTERY }
|
||||
|
||||
private val batteryTypeface by lazy {
|
||||
Typeface.createFromAsset(context.assets, "font/number.ttf")
|
||||
}
|
||||
|
||||
private var battery: Int = 0
|
||||
|
||||
var text: CharSequence?
|
||||
@@ -72,8 +68,6 @@ class BatteryView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
BatteryMode.CLASSIC -> {
|
||||
binding.batteryText.typeface = batteryTypeface
|
||||
binding.batteryTextInner.typeface = batteryTypeface
|
||||
binding.batteryClassic.isBattery = true
|
||||
binding.batteryClassic.textSize = 11f
|
||||
binding.batteryClassic.setBattery(battery, text)
|
||||
@@ -140,7 +134,7 @@ class BatteryView @JvmOverloads constructor(
|
||||
}
|
||||
BatteryMode.ARROW -> {
|
||||
binding.batteryText.visibility = VISIBLE
|
||||
binding.batteryTextEnd.visibility = VISIBLE
|
||||
binding.batteryTextEnd.visibility = GONE
|
||||
binding.batteryTextInner.visibility = GONE
|
||||
binding.batteryFill.visibility = GONE
|
||||
binding.batteryIcon.visibility = GONE
|
||||
@@ -168,6 +162,9 @@ class BatteryView @JvmOverloads constructor(
|
||||
BatteryMode.NO_BATTERY -> {
|
||||
binding.batteryFill.visibility = GONE
|
||||
binding.batteryIcon.visibility = GONE
|
||||
binding.batteryText.visibility = VISIBLE
|
||||
binding.batteryTextEnd.visibility = GONE
|
||||
binding.batteryTextInner.visibility = GONE
|
||||
binding.arrowIcon.visibility = GONE
|
||||
binding.batteryClassic.visibility = GONE
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<TextView
|
||||
android:id="@+id/battery_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:includeFontPadding="false"
|
||||
android:textSize="11sp"
|
||||
android:text="@string/text"
|
||||
@@ -32,7 +32,7 @@
|
||||
<TextView
|
||||
android:id="@+id/battery_text_inner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginEnd="2.4dp"
|
||||
android:layout_marginBottom="0.8dp"
|
||||
android:textSize="8sp"
|
||||
@@ -71,7 +71,7 @@
|
||||
<TextView
|
||||
android:id="@+id/battery_text_end"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
android:includeFontPadding="false"
|
||||
android:textSize="11sp"
|
||||
@@ -86,7 +86,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/text"
|
||||
android:visibility="gone"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintStart_toEndOf="@id/battery_icon"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
Reference in New Issue
Block a user