From fed161b088d1581c0d67e79aa8b57af18acf55b6 Mon Sep 17 00:00:00 2001 From: lvmeng <848755140@qq.com> Date: Fri, 24 Apr 2026 16:23:15 +0800 Subject: [PATCH] =?UTF-8?q?style(adapter):=20=E6=9B=B4=E6=96=B0=E7=BD=91?= =?UTF-8?q?=E6=A0=BC=E9=80=82=E9=85=8D=E5=99=A8=E9=AB=98=E4=BA=AE=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 setBackgroundColor 替换为 setBackgroundResource 使用形状资源 - 为 Seasoning18GridAdapter 和 Seasoning22GridAdapter 统一高亮样式 - 添加 shape_scale_cell_highlight.xml 定义圆角橙色背景 - 移除硬编码颜色值,提高样式可维护性 --- .../shuwei/dish/match/adapter/Seasoning18GridAdapter.kt | 2 +- .../shuwei/dish/match/adapter/Seasoning22GridAdapter.kt | 2 +- app/src/main/res/drawable/shape_scale_cell_highlight.xml | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/drawable/shape_scale_cell_highlight.xml diff --git a/app/src/main/java/com/shuwei/dish/match/adapter/Seasoning18GridAdapter.kt b/app/src/main/java/com/shuwei/dish/match/adapter/Seasoning18GridAdapter.kt index 7f2256c..46e5223 100644 --- a/app/src/main/java/com/shuwei/dish/match/adapter/Seasoning18GridAdapter.kt +++ b/app/src/main/java/com/shuwei/dish/match/adapter/Seasoning18GridAdapter.kt @@ -93,7 +93,7 @@ class Seasoning18GridAdapter( holder.b.tvState.text = stateStr(item.state) } if (position == highlightedPosition) { - holder.b.root.setBackgroundColor(ContextCompat.getColor(holder.b.root.context, R.color.red_ff4444)) + holder.b.root.setBackgroundResource(R.drawable.shape_scale_cell_highlight) val white = ContextCompat.getColor(holder.b.root.context, R.color.white) holder.b.tvAddress.setTextColor(white) holder.b.tvName.setTextColor(white) diff --git a/app/src/main/java/com/shuwei/dish/match/adapter/Seasoning22GridAdapter.kt b/app/src/main/java/com/shuwei/dish/match/adapter/Seasoning22GridAdapter.kt index 0ea05a6..46cba74 100644 --- a/app/src/main/java/com/shuwei/dish/match/adapter/Seasoning22GridAdapter.kt +++ b/app/src/main/java/com/shuwei/dish/match/adapter/Seasoning22GridAdapter.kt @@ -95,7 +95,7 @@ class Seasoning22GridAdapter( } // 高亮格子:红底白字;其余恢复默认 if (position == highlightedPosition) { - holder.b.root.setBackgroundColor(ContextCompat.getColor(holder.b.root.context, R.color.red_ff4444)) + holder.b.root.setBackgroundResource(R.drawable.shape_scale_cell_highlight) val white = ContextCompat.getColor(holder.b.root.context, R.color.white) holder.b.tvAddress.setTextColor(white) holder.b.tvName.setTextColor(white) diff --git a/app/src/main/res/drawable/shape_scale_cell_highlight.xml b/app/src/main/res/drawable/shape_scale_cell_highlight.xml new file mode 100644 index 0000000..ec5cb62 --- /dev/null +++ b/app/src/main/res/drawable/shape_scale_cell_highlight.xml @@ -0,0 +1,7 @@ + + + + + +