fix: 修复下拉手势无响应,改用自定义SwipeDownLayout

ViewPager2内部RecyclerView会拦截触摸事件,导致setOnTouchListener
和GestureDetector都收不到下拉手势。

改用SwipeDownLayout(自定义FrameLayout),在onInterceptTouchEvent中
检测下拉——事件到达子View之前就能观察到,原理同SwipeRefreshLayout。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
dongliang
2026-04-28 21:03:03 +09:30
parent 97a3054db2
commit 6021171a40
3 changed files with 89 additions and 37 deletions

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 首页容器:固定状态栏 + ViewPager2 + 打卡面板覆盖层 -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.xiaoqu.watch.ui.widget.SwipeDownLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipeDownLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background">
@@ -43,4 +44,4 @@
android:layout_height="match_parent"
android:visibility="gone" />
</FrameLayout>
</com.xiaoqu.watch.ui.widget.SwipeDownLayout>