fix: 状态栏固定在顶部,不随ViewPager2滑动

- 状态栏从两个子页面移到fragment_home.xml顶层
- ViewPager2在状态栏下方滑动
- HomeFragment只维护一个固定statusBar引用

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
dongliang
2026-04-27 19:47:31 +09:30
parent 2df2cd0cc2
commit 7a777e28a6
4 changed files with 27 additions and 33 deletions

View File

@@ -1,13 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 首页容器ViewPager2 左右滑动(设置页 / 主页) -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<!-- 首页容器:固定状态栏 + ViewPager2 左右滑动 -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background">
android:background="@color/background"
android:orientation="vertical"
android:paddingStart="21dp"
android:paddingTop="27dp"
android:paddingEnd="21dp">
<!-- 固定状态栏(不随 ViewPager2 滑动) -->
<com.xiaoqu.watch.ui.widget.StatusBarView
android:id="@+id/statusBar"
android:layout_width="match_parent"
android:layout_height="24dp"
android:layout_marginBottom="3dp" />
<!-- ViewPager2 在状态栏下方滑动 -->
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="0dp"
android:layout_weight="1" />
</FrameLayout>
</LinearLayout>

View File

@@ -6,17 +6,8 @@
android:layout_height="match_parent"
android:background="@color/background"
android:orientation="vertical"
android:paddingStart="21dp"
android:paddingTop="27dp"
android:paddingEnd="21dp"
android:paddingBottom="27dp">
<!-- 状态栏 18px → 24dp -->
<com.xiaoqu.watch.ui.widget.StatusBarView
android:id="@+id/statusBar"
android:layout_width="match_parent"
android:layout_height="24dp" />
<!-- 可滚动内容区 -->
<ScrollView
android:layout_width="match_parent"

View File

@@ -7,18 +7,8 @@
android:layout_height="match_parent"
android:background="@color/background"
android:orientation="vertical"
android:paddingStart="21dp"
android:paddingTop="27dp"
android:paddingEnd="21dp"
android:paddingBottom="27dp">
<!-- 状态栏 18px → 24dp -->
<com.xiaoqu.watch.ui.widget.StatusBarView
android:id="@+id/statusBar"
android:layout_width="match_parent"
android:layout_height="24dp"
android:layout_marginBottom="3dp" />
<!-- 时钟区域flex:1 撑满中间) -->
<LinearLayout
android:layout_width="match_parent"