Просмотр исходного кода

修复阅读背景配置时不显示文字的问题

HapeLee 1 год назад
Родитель
Сommit
d1e46b2a62

+ 1 - 2
app/src/main/java/io/legato/kazusa/ui/book/read/config/BgAdapter.kt

@@ -25,14 +25,13 @@ class BgAdapter(context: Context, val textColor: Int) :
         payloads: MutableList<Any>
     ) {
         binding.run {
+            tvName.text = item.substringBeforeLast(".")
             ImageLoader.load(
                 context,
                 context.assets.open("bg${File.separator}$item").readBytes()
             )
                 .centerCrop()
                 .into(ivBg)
-            tvName.setTextColor(textColor)
-            tvName.text = item.substringBeforeLast(".")
         }
     }
 

+ 1 - 4
app/src/main/java/io/legato/kazusa/ui/book/read/config/BgTextConfigDialog.kt

@@ -2,7 +2,6 @@ package io.legato.kazusa.ui.book.read.config
 
 import android.annotation.SuppressLint
 import android.content.DialogInterface
-import android.graphics.PorterDuff
 import android.net.Uri
 import android.os.Bundle
 import android.view.View
@@ -115,10 +114,8 @@ class BgTextConfigDialog : BaseBottomSheetDialogFragment(R.layout.dialog_read_bg
         recyclerView.adapter = adapter
         adapter.addHeaderView {
             ItemBgImageBinding.inflate(layoutInflater, it, false).apply {
-                tvName.setTextColor(secondaryTextColor)
                 tvName.text = getString(R.string.select_image)
-                ivBg.setImageResource(R.drawable.ic_image)
-                ivBg.setColorFilter(primaryTextColor, PorterDuff.Mode.SRC_IN)
+                ivBg.setImageResource(R.drawable.ic_add)
                 swUnderline.isGone = ReadBook.book?.isImage == true
                 root.setOnClickListener {
                     selectBgImage.launch()

+ 6 - 4
app/src/main/res/layout/item_bg_image.xml

@@ -1,8 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="66dp"
-    android:layout_height="88dp"
-    xmlns:tool="http://schemas.android.com/tools"
+    android:layout_height="98dp"
     android:layout_marginEnd="6dp"
     android:orientation="vertical">
 
@@ -17,9 +16,9 @@
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:contentDescription="@string/bg_image"
-            android:foreground="?android:attr/selectableItemBackground"
+            android:background="?android:attr/selectableItemBackground"
             android:scaleType="fitCenter"
-            tool:src="@drawable/ic_image" />
+            android:src="@drawable/ic_add" />
 
     </com.google.android.material.card.MaterialCardView>
 
@@ -27,6 +26,9 @@
         android:id="@+id/tv_name"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
+        android:layout_marginTop="4dp"
+        android:textSize="12sp"
+        android:textStyle="bold"
         android:text="@string/text"
         android:singleLine="true"
         android:gravity="center" />