style(adapter): 更新网格适配器高亮样式

- 将 setBackgroundColor 替换为 setBackgroundResource 使用形状资源
- 为 Seasoning18GridAdapter 和 Seasoning22GridAdapter 统一高亮样式
- 添加 shape_scale_cell_highlight.xml 定义圆角橙色背景
- 移除硬编码颜色值,提高样式可维护性
This commit is contained in:
2026-04-24 16:23:15 +08:00
parent 594c551a98
commit fed161b088
3 changed files with 9 additions and 2 deletions
@@ -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)
@@ -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)
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 秤格子背景:白色底 + 灰色描边 + 圆角,与页面蓝色背景形成对比 -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FA9523" />
<corners android:radius="8dp" />
</shape>