2026-11-29 13:54:10 +08:00
|
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
|
|
<!--
|
|
|
|
|
|
锁屏全屏倒计时·横屏专属排版(区别于竖屏的纯纵向堆叠):
|
2026-11-30 00:44:14 +08:00
|
|
|
|
左右对称分栏——左侧倒计时(大)+ 任务名,右侧时钟(大)+ 日期星期,
|
|
|
|
|
|
两侧主字号统一 130sp,视觉左右对应;无「工作中/休息中」提示。
|
|
|
|
|
|
|
|
|
|
|
|
分割线:保持最初可见版本的原始实现——静态 View 直接放在两栏之间,
|
|
|
|
|
|
固定 dp 高度,无任何运行时改动(此前的 View.post / fontMetrics /
|
|
|
|
|
|
match_parent 结构化三版方案在锁屏/悬浮窗链路上全部失效)。
|
|
|
|
|
|
高度 150dp ≈ 130sp 时间文字的墨迹高度(1.17 × 130sp),仅分割两块大时间。
|
2026-11-30 01:28:49 +08:00
|
|
|
|
|
2026-11-30 07:51:44 +08:00
|
|
|
|
v2.2/v2.3 位置对齐:分割线作为横排直系子 View 时,center_vertical 相对「整个
|
|
|
|
|
|
左右两栏(时间+10dp间距+15sp小字)」居中,下方多出的一截把线的中心往下拉。
|
|
|
|
|
|
v2.2 只在分割线外套锚点 FrameLayout,但锚点列比侧栏矮(没有补小字占位),
|
|
|
|
|
|
三列各自居中后锚点中心仍落在屏幕中心,位置不变、修复无效。
|
|
|
|
|
|
v2.3 改为中列完整镜像左右两栏(时间锚点 + 同规格小字占位),三列同高同顶,
|
|
|
|
|
|
锚点中心严格等于时间文字中心;纯静态 XML,不受锁屏/悬浮窗特殊窗口运行时
|
|
|
|
|
|
调整失效问题影响,字体缩放变化也同步。
|
2026-11-30 08:19:49 +08:00
|
|
|
|
|
|
|
|
|
|
v2.4 左右等距:v2.3 后用户反馈线到两边时间的左右间隙不相等。实测 Roboto
|
|
|
|
|
|
数字等宽且布局对称,间隙不等只可能来自系统字体(鸿蒙 HarmonyOS Sans)
|
|
|
|
|
|
数字非等宽,或倒计时 ≥100 分钟时多出一位。对策:①左栏改右对齐、右栏改
|
|
|
|
|
|
左对齐,各距分割线固定 24dp——布局间隙无条件相等,不依赖文字宽度;
|
|
|
|
|
|
②两侧大时间与锚点加 fontFeatureSettings=tnum,系统字体支持时强制数字
|
|
|
|
|
|
等宽,连墨迹抖动也消除(不支持时无副作用)。
|
2026-11-29 13:54:10 +08:00
|
|
|
|
-->
|
|
|
|
|
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
|
|
|
|
android:id="@+id/lockRoot"
|
|
|
|
|
|
android:layout_width="match_parent"
|
|
|
|
|
|
android:layout_height="match_parent"
|
|
|
|
|
|
android:background="@android:color/black"
|
|
|
|
|
|
android:clickable="true"
|
|
|
|
|
|
android:focusable="true"
|
2026-11-30 00:44:14 +08:00
|
|
|
|
android:gravity="center_vertical"
|
|
|
|
|
|
android:orientation="horizontal">
|
2026-11-29 13:54:10 +08:00
|
|
|
|
|
2026-11-30 08:19:49 +08:00
|
|
|
|
<!-- 左:倒计时 + 任务名(右对齐贴线:右缘距分割线固定 24dp,
|
2026-11-30 08:40:17 +08:00
|
|
|
|
与右栏对称,保证线到两边时间的布局间隙恒相等)
|
|
|
|
|
|
v2.5:倒计时 ≥100 分钟时是 6 位数(如 120:00),130sp 下宽约 410dp,
|
|
|
|
|
|
超出半屏可用宽度,wrap_content 会被压缩且文字从框左缘起画、越过分割线
|
|
|
|
|
|
——v2.4「装不下/越过线」的根因。改为 match_parent 定宽 + autoSize
|
|
|
|
|
|
自动缩号(上限仍 130sp):5 位数保持 130sp 原样,6 位数缩到刚好装下,
|
|
|
|
|
|
永不溢出。时间列结构「时间+10dp+小字」整体居中,时间中心=列中心
|
|
|
|
|
|
-(10+小字)/2,与字号无关 → 一侧缩号不破坏竖向对齐。 -->
|
2026-11-29 13:54:10 +08:00
|
|
|
|
<LinearLayout
|
2026-11-30 00:44:14 +08:00
|
|
|
|
android:layout_width="0dp"
|
2026-11-29 13:54:10 +08:00
|
|
|
|
android:layout_height="wrap_content"
|
2026-11-30 00:44:14 +08:00
|
|
|
|
android:layout_weight="1"
|
2026-11-30 08:19:49 +08:00
|
|
|
|
android:gravity="center_vertical|end"
|
2026-11-30 00:44:14 +08:00
|
|
|
|
android:orientation="vertical">
|
2026-11-29 13:54:10 +08:00
|
|
|
|
|
2026-11-30 00:44:14 +08:00
|
|
|
|
<TextView
|
|
|
|
|
|
android:id="@+id/tvLockCountdown"
|
2026-11-30 08:40:17 +08:00
|
|
|
|
android:layout_width="match_parent"
|
2026-11-29 13:54:10 +08:00
|
|
|
|
android:layout_height="wrap_content"
|
2026-11-30 08:19:49 +08:00
|
|
|
|
android:layout_marginEnd="24dp"
|
2026-11-30 08:40:17 +08:00
|
|
|
|
android:autoSizeTextType="uniform"
|
|
|
|
|
|
android:autoSizeMinTextSize="40sp"
|
|
|
|
|
|
android:autoSizeMaxTextSize="130sp"
|
2026-11-30 08:19:49 +08:00
|
|
|
|
android:fontFeatureSettings="tnum"
|
2026-11-30 08:40:17 +08:00
|
|
|
|
android:gravity="center_vertical|end"
|
2026-11-30 00:44:14 +08:00
|
|
|
|
android:includeFontPadding="false"
|
|
|
|
|
|
android:textColor="#FFFFFF"
|
|
|
|
|
|
android:textStyle="bold" />
|
2026-11-30 00:28:57 +08:00
|
|
|
|
|
2026-11-30 00:44:14 +08:00
|
|
|
|
<TextView
|
|
|
|
|
|
android:id="@+id/tvLockTask"
|
|
|
|
|
|
android:layout_width="wrap_content"
|
2026-11-29 13:54:10 +08:00
|
|
|
|
android:layout_height="wrap_content"
|
2026-11-30 00:44:14 +08:00
|
|
|
|
android:layout_marginTop="10dp"
|
2026-11-30 08:19:49 +08:00
|
|
|
|
android:layout_marginEnd="24dp"
|
2026-11-30 00:44:14 +08:00
|
|
|
|
android:ellipsize="end"
|
|
|
|
|
|
android:maxWidth="320dp"
|
|
|
|
|
|
android:maxLines="1"
|
|
|
|
|
|
android:textColor="#99FFFFFF"
|
|
|
|
|
|
android:textSize="15sp" />
|
2026-11-30 00:28:57 +08:00
|
|
|
|
</LinearLayout>
|
2026-11-29 13:54:10 +08:00
|
|
|
|
|
2026-11-30 01:28:49 +08:00
|
|
|
|
<!-- 中:细分隔线(92dp≈130sp 粗体数字的字面高度 0.71em×130,与时间视觉等高)
|
2026-11-30 07:51:44 +08:00
|
|
|
|
v2.3 中列完整镜像左右两栏:上方 1dp FrameLayout 内放与时间同规格的 130sp
|
|
|
|
|
|
不可见锚点文字(maxLines=1,防止 1dp 宽度触发折行撑高),分割线在其中
|
|
|
|
|
|
center;下方补一段与侧栏小字同规格(15sp、marginTop 10dp)的不可见占位,
|
|
|
|
|
|
使中列总高与左右两栏一致。三列同高且都被 center_vertical 居中 → 同顶,
|
|
|
|
|
|
锚点中心严格等于时间文字中心。(v2.2 只放了锚点没补占位,中列比侧栏矮
|
|
|
|
|
|
一截,居中后中心仍落在屏幕中心,与旧版位置相同,故无效) -->
|
|
|
|
|
|
<LinearLayout
|
|
|
|
|
|
android:layout_width="wrap_content"
|
|
|
|
|
|
android:layout_height="wrap_content"
|
|
|
|
|
|
android:orientation="vertical">
|
|
|
|
|
|
|
|
|
|
|
|
<FrameLayout
|
|
|
|
|
|
android:layout_width="1dp"
|
|
|
|
|
|
android:layout_height="wrap_content">
|
|
|
|
|
|
|
2026-11-30 08:19:49 +08:00
|
|
|
|
<TextView
|
|
|
|
|
|
android:layout_width="wrap_content"
|
|
|
|
|
|
android:layout_height="wrap_content"
|
|
|
|
|
|
android:fontFeatureSettings="tnum"
|
|
|
|
|
|
android:includeFontPadding="false"
|
|
|
|
|
|
android:maxLines="1"
|
|
|
|
|
|
android:visibility="invisible"
|
|
|
|
|
|
android:text="00:00"
|
|
|
|
|
|
android:textSize="130sp"
|
|
|
|
|
|
android:textStyle="bold" />
|
2026-11-30 07:51:44 +08:00
|
|
|
|
|
|
|
|
|
|
<View
|
|
|
|
|
|
android:id="@+id/lockDivider"
|
|
|
|
|
|
android:layout_width="1dp"
|
|
|
|
|
|
android:layout_height="92dp"
|
|
|
|
|
|
android:layout_gravity="center"
|
|
|
|
|
|
android:background="#26FFFFFF" />
|
|
|
|
|
|
</FrameLayout>
|
2026-11-30 01:28:49 +08:00
|
|
|
|
|
|
|
|
|
|
<TextView
|
|
|
|
|
|
android:layout_width="wrap_content"
|
|
|
|
|
|
android:layout_height="wrap_content"
|
2026-11-30 07:51:44 +08:00
|
|
|
|
android:layout_marginTop="10dp"
|
|
|
|
|
|
android:maxLines="1"
|
2026-11-30 01:28:49 +08:00
|
|
|
|
android:visibility="invisible"
|
2026-11-30 07:51:44 +08:00
|
|
|
|
android:text="0"
|
|
|
|
|
|
android:textSize="15sp" />
|
|
|
|
|
|
</LinearLayout>
|
2026-11-30 00:44:14 +08:00
|
|
|
|
|
2026-11-30 08:40:17 +08:00
|
|
|
|
<!-- 右:时钟(大)+ 日期星期在时钟下面(左对齐贴线:左缘距分割线固定 24dp;
|
|
|
|
|
|
与左栏同样 match_parent 定宽 + autoSize,字体缩放变大或位数变多时
|
|
|
|
|
|
自动缩号,永不溢出屏幕) -->
|
2026-11-29 13:54:10 +08:00
|
|
|
|
<LinearLayout
|
2026-11-30 00:44:14 +08:00
|
|
|
|
android:layout_width="0dp"
|
2026-11-29 13:54:10 +08:00
|
|
|
|
android:layout_height="wrap_content"
|
2026-11-30 00:44:14 +08:00
|
|
|
|
android:layout_weight="1"
|
2026-11-30 08:19:49 +08:00
|
|
|
|
android:gravity="center_vertical|start"
|
2026-11-30 00:44:14 +08:00
|
|
|
|
android:orientation="vertical">
|
2026-11-29 13:54:10 +08:00
|
|
|
|
|
2026-11-30 00:44:14 +08:00
|
|
|
|
<TextView
|
|
|
|
|
|
android:id="@+id/tvLockClock"
|
2026-11-30 08:40:17 +08:00
|
|
|
|
android:layout_width="match_parent"
|
2026-11-29 13:54:10 +08:00
|
|
|
|
android:layout_height="wrap_content"
|
2026-11-30 08:19:49 +08:00
|
|
|
|
android:layout_marginStart="24dp"
|
2026-11-30 08:40:17 +08:00
|
|
|
|
android:autoSizeTextType="uniform"
|
|
|
|
|
|
android:autoSizeMinTextSize="40sp"
|
|
|
|
|
|
android:autoSizeMaxTextSize="130sp"
|
2026-11-30 08:19:49 +08:00
|
|
|
|
android:fontFeatureSettings="tnum"
|
2026-11-30 08:40:17 +08:00
|
|
|
|
android:gravity="center_vertical|start"
|
2026-11-30 00:44:14 +08:00
|
|
|
|
android:includeFontPadding="false"
|
|
|
|
|
|
android:textColor="#FFFFFF"
|
|
|
|
|
|
android:textStyle="bold" />
|
2026-11-30 00:28:57 +08:00
|
|
|
|
|
2026-11-30 00:44:14 +08:00
|
|
|
|
<TextView
|
|
|
|
|
|
android:id="@+id/tvLockDate"
|
|
|
|
|
|
android:layout_width="wrap_content"
|
2026-11-29 13:54:10 +08:00
|
|
|
|
android:layout_height="wrap_content"
|
2026-11-30 00:44:14 +08:00
|
|
|
|
android:layout_marginTop="10dp"
|
2026-11-30 08:19:49 +08:00
|
|
|
|
android:layout_marginStart="24dp"
|
2026-11-30 00:44:14 +08:00
|
|
|
|
android:textColor="#99FFFFFF"
|
|
|
|
|
|
android:textSize="15sp" />
|
2026-11-29 13:54:10 +08:00
|
|
|
|
</LinearLayout>
|
|
|
|
|
|
|
|
|
|
|
|
</LinearLayout>
|