回退v2.3布局基线,撤销autoSize;新增CountdownFit按实测字宽把6位倒计时缩到与时钟等宽修复左右间隙不等(v2.6)
This commit is contained in:
@@ -16,13 +16,6 @@
|
||||
v2.3 改为中列完整镜像左右两栏(时间锚点 + 同规格小字占位),三列同高同顶,
|
||||
锚点中心严格等于时间文字中心;纯静态 XML,不受锁屏/悬浮窗特殊窗口运行时
|
||||
调整失效问题影响,字体缩放变化也同步。
|
||||
|
||||
v2.4 左右等距:v2.3 后用户反馈线到两边时间的左右间隙不相等。实测 Roboto
|
||||
数字等宽且布局对称,间隙不等只可能来自系统字体(鸿蒙 HarmonyOS Sans)
|
||||
数字非等宽,或倒计时 ≥100 分钟时多出一位。对策:①左栏改右对齐、右栏改
|
||||
左对齐,各距分割线固定 24dp——布局间隙无条件相等,不依赖文字宽度;
|
||||
②两侧大时间与锚点加 fontFeatureSettings=tnum,系统字体支持时强制数字
|
||||
等宽,连墨迹抖动也消除(不支持时无副作用)。
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/lockRoot"
|
||||
@@ -34,33 +27,21 @@
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<!-- 左:倒计时 + 任务名(右对齐贴线:右缘距分割线固定 24dp,
|
||||
与右栏对称,保证线到两边时间的布局间隙恒相等)
|
||||
v2.5:倒计时 ≥100 分钟时是 6 位数(如 120:00),130sp 下宽约 410dp,
|
||||
超出半屏可用宽度,wrap_content 会被压缩且文字从框左缘起画、越过分割线
|
||||
——v2.4「装不下/越过线」的根因。改为 match_parent 定宽 + autoSize
|
||||
自动缩号(上限仍 130sp):5 位数保持 130sp 原样,6 位数缩到刚好装下,
|
||||
永不溢出。时间列结构「时间+10dp+小字」整体居中,时间中心=列中心
|
||||
-(10+小字)/2,与字号无关 → 一侧缩号不破坏竖向对齐。 -->
|
||||
<!-- 左:倒计时 + 任务名 -->
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical|end"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvLockCountdown"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:autoSizeMinTextSize="40sp"
|
||||
android:autoSizeMaxTextSize="130sp"
|
||||
android:fontFeatureSettings="tnum"
|
||||
android:gravity="center_vertical|end"
|
||||
android:includeFontPadding="false"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="130sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
@@ -68,7 +49,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:ellipsize="end"
|
||||
android:maxWidth="320dp"
|
||||
android:maxLines="1"
|
||||
@@ -92,16 +72,15 @@
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<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" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:visibility="invisible"
|
||||
android:text="00:00"
|
||||
android:textSize="130sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<View
|
||||
android:id="@+id/lockDivider"
|
||||
@@ -121,28 +100,21 @@
|
||||
android:textSize="15sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 右:时钟(大)+ 日期星期在时钟下面(左对齐贴线:左缘距分割线固定 24dp;
|
||||
与左栏同样 match_parent 定宽 + autoSize,字体缩放变大或位数变多时
|
||||
自动缩号,永不溢出屏幕) -->
|
||||
<!-- 右:时钟(大)+ 日期星期在时钟下面 -->
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical|start"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvLockClock"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="24dp"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:autoSizeMinTextSize="40sp"
|
||||
android:autoSizeMaxTextSize="130sp"
|
||||
android:fontFeatureSettings="tnum"
|
||||
android:gravity="center_vertical|start"
|
||||
android:includeFontPadding="false"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="130sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
@@ -150,7 +122,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="24dp"
|
||||
android:textColor="#99FFFFFF"
|
||||
android:textSize="15sp" />
|
||||
</LinearLayout>
|
||||
|
||||
Reference in New Issue
Block a user