fix: 返回按钮改为整个标题栏左半边可点击
去掉 TouchDelegate,改用 FrameLayout 占标题栏左半边(weight=1) 图标靠左显示,但整个左半边 48dp 高的区域都能触发返回 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -87,19 +87,10 @@ class TaskListFragment : BaseFragment<FragmentTaskListBinding>() {
|
|||||||
val dialogContainer = requireActivity().findViewById<FrameLayout>(R.id.dialog_container)
|
val dialogContainer = requireActivity().findViewById<FrameLayout>(R.id.dialog_container)
|
||||||
tipDialog = QuTipDialog(dialogContainer)
|
tipDialog = QuTipDialog(dialogContainer)
|
||||||
|
|
||||||
// 返回按钮(扩大触摸区域,图标大小不变)
|
// 返回按钮(整个左半边都可点击)
|
||||||
binding.btnBack.setOnClickListener {
|
binding.btnBack.setOnClickListener {
|
||||||
findNavController().popBackStack()
|
findNavController().popBackStack()
|
||||||
}
|
}
|
||||||
// 用 TouchDelegate 向下和向右扩展点击区域
|
|
||||||
binding.btnBack.post {
|
|
||||||
val parent = binding.btnBack.parent as View
|
|
||||||
val rect = android.graphics.Rect()
|
|
||||||
binding.btnBack.getHitRect(rect)
|
|
||||||
rect.bottom += (20 * resources.displayMetrics.density).toInt()
|
|
||||||
rect.right += (40 * resources.displayMetrics.density).toInt()
|
|
||||||
parent.touchDelegate = android.view.TouchDelegate(rect, binding.btnBack)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 左右滑手势(切换任务),上下滑留给内容滚动
|
// 左右滑手势(切换任务),上下滑留给内容滚动
|
||||||
gestureDetector = GestureDetector(requireContext(), object : GestureDetector.SimpleOnGestureListener() {
|
gestureDetector = GestureDetector(requireContext(), object : GestureDetector.SimpleOnGestureListener() {
|
||||||
|
|||||||
@@ -19,16 +19,25 @@
|
|||||||
android:paddingEnd="21dp"
|
android:paddingEnd="21dp"
|
||||||
android:paddingBottom="4dp">
|
android:paddingBottom="4dp">
|
||||||
|
|
||||||
<!-- 返回按钮:iconfont 图标,点击区域由 TouchDelegate 扩展 -->
|
<!-- 返回按钮:整个左半边可点击,图标靠左 -->
|
||||||
<TextView
|
<FrameLayout
|
||||||
android:id="@+id/btnBack"
|
android:id="@+id/btnBack"
|
||||||
android:layout_width="64dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="48dp"
|
||||||
android:gravity="center"
|
android:layout_weight="1"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:paddingStart="21dp"
|
||||||
android:text="\ue6bd"
|
android:text="\ue6bd"
|
||||||
android:fontFamily="@font/iconfont"
|
android:fontFamily="@font/iconfont"
|
||||||
android:textColor="@color/text_primary"
|
android:textColor="@color/text_primary"
|
||||||
android:textSize="28sp" />
|
android:textSize="28sp" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvTitle"
|
android:id="@+id/tvTitle"
|
||||||
|
|||||||
Reference in New Issue
Block a user