'How to implement RecyclerView scrolling with Tooltip?

I have to implement Tooltip that is shown on top of RecyclerView elements and it should scroll vertically and horizontally.

Ideally I need to have AdapterDelegates which have horizontal and vertical RecyclerViews. By clicking on the inflated View of those RecyclerViews, Tooltip appears and it is not dismissed until clicking on the View again.

Though if I use ScrollView for vertical scrolling then Tooltip scrolls, but when I try to scroll horizontally in RecyclerView then Tooltip stays in the same spot (see GIF below)

I also tried to override onInterceptTouchEvent or to play with onTouchListener:

switch (motionEvent.getAction()) {
   case MotionEvent.ACTION_DOWN:
      dx = (int) (view.getX() - motionEvent.getRawX());
      dy = (int) (view.getY() - motionEvent.getRawY());
      return true;
   case MotionEvent.ACTION_MOVE:
      view.setX(motionEvent.getRawX() + dx);
      view.setY(motionEvent.getRawY() + dy);
      return true;
   }
return false;

But as example below shows then Tooltip consumes touch event and except Tooltip itself nothing moves:

movable tooltip

I tried many popular Tooltip libraries, but all of them didn't had the functionality I needed.

How can I achieve desired functionality?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source