Android:在 touch_down 事件上标记视图的子元素

Android: Tag child element of a view on touch_down event

我有这个架构(带有 View 和 RecyclerView 的 ViewGroup):

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.wacom.matchapoc.MainActivity"
    tools:showIn="@layout/activity_main">

    <com.wacom.matchapoc.view.SmartRecyclerView
        android:id="@+id/my_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:scrollbars="vertical" />

    <com.wacom.matchapoc.view.DrawingView
        android:id="@+id/drawingView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</FrameLayout>

DrawingViewRecyclerView 之上并且有一个 Overridden onTouch() 事件,所以当 isEnableDrawing() 标志为真时(您可以从设置中设置它在主要 activity) 中,它处理 touch_down/move/up 事件,以便您可以绘制 RecyclerView 中的元素。

我现在要做的,本质上就是把DrawingView上的用户画图link到RecyclerView的子元素(文字、图片等)上。为此,我需要知道 RecyclerView 的哪个子元素位于初始 touch_down(x,y) 坐标下,标记它然后继续绘制。

目前我有这些问题:

  1. 我不确定 RecyclerViewgetFocusedChild() 方法是否会正确 return touch_down(x,y);
  2. 下的子元素
  3. 为了让触摸事件传递到RecyclerView,我需要在DrawingView中不消费它,然后在RecyclerView中标记子元素而不消费再一次,然后 return 它到 DrawingView 并继续绘图。

这对我来说相当困难,因为我最近才开始 Android 编程并且对 API 及其工作原理不是很熟悉。

关于如何 link/tag 子元素的任何建议,以便我可以很容易地知道哪个 drawing/path 属于哪个子元素将是最受欢迎的。

显然 RecyclerView 中有一个名为 findChildViewUnder() 的方法可以满足我的需要。