Class MapTouchWrapper

All Implemented Interfaces:
Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback, ViewManager, ViewParent

public class MapTouchWrapper extends FrameLayout
A custom FrameLayout that intercepts touch events and notifies a listener when touched. This is particularly useful when embedding interactive views like maps inside scrollable containers, such as ScrollViews. By notifying a listener on touch, it allows the parent to handle scroll disabling or other gesture-related behaviors.
  • Constructor Details

    • MapTouchWrapper

      public MapTouchWrapper(Context context)
      Constructs a new MapTouchWrapper with the specified context.
      Parameters:
      context - the application context
    • MapTouchWrapper

      public MapTouchWrapper(Context context, AttributeSet attrs)
      Constructs a new MapTouchWrapper with the specified context and attribute set.
      Parameters:
      context - the application context
      attrs - the attribute set from XML
  • Method Details

    • setOnTouchListener

      public void setOnTouchListener(Runnable listener)
      Sets a listener that will be executed when the view is touched.
      Parameters:
      listener - the Runnable to run on touch events
    • dispatchTouchEvent

      public boolean dispatchTouchEvent(MotionEvent ev)
      Intercepts and dispatches touch events to the view hierarchy. Executes the provided onTouchListener if one is set.
      Overrides:
      dispatchTouchEvent in class ViewGroup
      Parameters:
      ev - the MotionEvent object containing full information about the event
      Returns:
      true if the event was handled, false otherwise