From ddaf41fee86bf4fc5e4d4c368726221389831156 Mon Sep 17 00:00:00 2001 From: laoyang Date: Mon, 2 Nov 2026 22:08:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=91=A8=E8=A7=86=E5=9B=BE):=20=E5=9C=86?= =?UTF-8?q?=E5=BE=84=E6=8C=89=E5=86=85=E5=AE=B9=E9=AB=98=E5=BA=A6=E9=80=82?= =?UTF-8?q?=E9=85=8D=EF=BC=8C=E4=BF=AE"=E4=B8=8A=E9=9C=B2=E6=98=9F?= =?UTF-8?q?=E6=9C=9F=E3=80=81=E4=B8=8B=E6=BC=8F=E5=9C=86=E7=82=B9"=20#6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用户反馈:周视图圆的上沿包进了"一"(星期标签),下沿却把事件点漏在外面。 ## 根因 周条加了星期标签后,内容实际高度约 147px: 星期 10px字号 ≈ 28 日期框 24vp ≈ 72 农历 9px字号 ≈ 27 事件点 3.5vp ≈ 11 3 个间隙 ≈ 9 合计 ≈ 147px 而圆固定 46vp = 138px ⇒ **内容比圆高 9px**。 Stack 的 alignContent 默认居中,导致内容上下对称溢出: 上面露出星期标签,下面漏掉事件点。 ## 修法 圆径按内容取,不搞一刀切: · 周条(showWeekLabel=true,内容≈147px)→ 54vp(≈162px) · 月视图(无星期标签,内容≈118px) → 46vp(≈138px) 同时 Stack 显式 alignContent(Alignment.Center),避免内容高于圆时对齐跑偏。 ## 验证(真机 dump 实测) 圆范围 y 495~664(169px) 星期"一" y 497~534 圆内 ✓ 日期"2" y 537~612 圆内 ✓ 农历"廿四" y 615~648 圆内 ✓ 事件点×7 y 651~662 圆内 ✓ ## 教训 Stack 里"固定尺寸的装饰元素"(圆)+ "不定高的内容"(文字块)组合时, 圆径必须 >= 内容高度,否则内容一定溢出。 这类问题看截图不容易发现(因为溢出部分常被裁掉或重叠), **必须 dump 出两者的 bounds 做数值比对**才准。 --- entry/src/main/ets/pages/Index.ets | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index b90024a..4f1a104 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -3311,20 +3311,26 @@ struct Index { */ @Builder dayCellCircle(cell: MonthCell, showWeekLabel: boolean = false) { - Stack() { + // 显式 Center:Stack 默认虽也居中,但内容高于圆时对齐行为容易偏, + // 写死更可控(周条曾是"上露星期、下漏圆点")。 + Stack({ alignContent: Alignment.Center }) { // ⭐ TODAY_RING 底层圆:选中用实蓝,今天用淡蓝,尺寸一致。 // 原来今天只在日期数字上贴了个 24×24 的小圈,选中却是 46vp 大圆, // 同一天"选不选中"看起来像两种东西。现在两者尺寸统一。 + // ⭐ RING_FIT 圆径必须**按内容高度**取,不能一刀切。 + // 周条比月历多一行"星期标签",内容约 147px;圆固定 46vp(138px) 时 + // 就会上露"一"、下漏事件点。周条用 54vp(≈162px) 才包得住。 + // 月视图没有星期标签、内容约 118px,46vp 刚好。 if (cell.dateMs === this.selectedDate) { Column() - .width(this.wideLayout ? 40 : 46) - .height(this.wideLayout ? 40 : 46) + .width(showWeekLabel ? 54 : (this.wideLayout ? 40 : 46)) + .height(showWeekLabel ? 54 : (this.wideLayout ? 40 : 46)) .borderRadius('50%') .backgroundColor($r('app.color.selected_bg')) } else if (cell.isToday) { Column() - .width(this.wideLayout ? 40 : 46) - .height(this.wideLayout ? 40 : 46) + .width(showWeekLabel ? 54 : (this.wideLayout ? 40 : 46)) + .height(showWeekLabel ? 54 : (this.wideLayout ? 40 : 46)) .borderRadius('50%') .backgroundColor($r('app.color.today_bg')) }