fix: 电池数字改为白字+黑色描边
黑字在黑色背景上看不见,白字在绿色填充上也不清楚 改用白色填充+黑色描边,在任何背景上都清晰可读 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -116,17 +116,24 @@ class StatusBarView @JvmOverloads constructor(
|
||||
canvas.drawRoundRect(fillRect, 2f, 2f, paint)
|
||||
|
||||
// 电池内部文字:充电时显示 ⚡,否则显示百分比
|
||||
// 深色文字确保在任何填充色上都清晰可读
|
||||
// 白色文字 + 黑色描边,在填充条和黑色背景上都清晰
|
||||
if (batteryLevel >= 0) {
|
||||
val text = if (isCharging) "⚡" else "${batteryLevel}"
|
||||
paint.style = Paint.Style.FILL
|
||||
paint.color = 0xFF000000.toInt()
|
||||
paint.textSize = 11f
|
||||
paint.textAlign = Paint.Align.CENTER
|
||||
paint.typeface = android.graphics.Typeface.DEFAULT_BOLD
|
||||
val metrics = paint.fontMetrics
|
||||
val baselineY = centerY - (metrics.ascent + metrics.descent) / 2
|
||||
canvas.drawText(text, startX + shellW / 2, baselineY, paint)
|
||||
val cx = startX + shellW / 2
|
||||
// 先画黑色描边(让白字在绿色填充上有边界)
|
||||
paint.style = Paint.Style.STROKE
|
||||
paint.strokeWidth = 2.5f
|
||||
paint.color = 0xFF000000.toInt()
|
||||
canvas.drawText(text, cx, baselineY, paint)
|
||||
// 再画白色填充
|
||||
paint.style = Paint.Style.FILL
|
||||
paint.color = 0xFFFFFFFF.toInt()
|
||||
canvas.drawText(text, cx, baselineY, paint)
|
||||
paint.textAlign = Paint.Align.LEFT
|
||||
paint.typeface = android.graphics.Typeface.DEFAULT
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user