Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8605917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:57:54+00:00 2026-06-12T02:57:54+00:00

I have a view that covers entire screen (let’s say ParentView ), and child

  • 0

I have a view that covers entire screen (let’s say ParentView), and child inner view ChildView that covers only portion of it.
I want to make ChildView to respond to onSingleTapUp(), while the ParentView respond to onFling(). I am trying to do so by attaching one SimpleOnGestureListener on ChildView and one SimpleOnGestureListener on ParentView.

To accept onSingleTapUp() from ChildView, its listener’s onDown() has to return true.
But once I do that, the listener tied to ParentView does not hear any motion events anymore since it is taken by the ChildView‘s listener. Even though ChildView‘s onFling() returns false, the events do not flow to the ParentView‘s listener.

How can I make the parent view’s listener catch the fling gesture while child view’s listener catch tap gesture?

I don’t think any source code is needed to explain the situation, but here is a snippet that sets up my ChildView listener.

ChildView.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {
        return singleTapGestureDetector.onTouchEvent(motionEvent);
    }
});

One workaround could be to have both ParentView and ChildView‘s listeners to handle onFling() while only ChildView‘s listener handle onSingleTapUp(), but in that case, fling won’t be able to happen across the ChildView (like start outside the child and then end within the child), I believe.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:57:55+00:00Added an answer on June 12, 2026 at 2:57 am

    I don’t like my solution, but I found a way to do this. Hopefully somebody else will post better answer in the future, or at least my workaround is useful to somebody otherwise.

    As I described in the question, the problem lies on how gesture listener works. For child view to catch onSingleTapUp() event, you return true on onDown(). But once you do that, the subsequent series of events won’t go to the parent view even after your child view’s onTouch() declares it is no longer interested in the event. If you forcefully call the parent’s onTouch() within the child’s onTouch() when its gesture detector returns false, yes the parent’s onFling() will be invoked but the first MouseEvent argument will be NULL since it was consumed by the child view’s onTouch().

    I must be missing something since this seems very basic gesture detection scenario. Anyway, I couldn’t find a way to do this in reasonable way.

    So, my workaround is to make TouchListenerService as a singleton.

    Both child view and parent view have this line:

    view.setOnTouchListener(TouchListenerService.Instance());
    

    and TouchListenerService starts like this:

    public class TouchListenerService
        extends GestureDetector.SimpleOnGestureListener
        implements View.OnTouchListener {
    
        // some code to implement singleton
    
        public SingleTapUpHandler SingleTapUpHandler;
        public FlingHandler FlingHandler;
    
        private View _touchingView;
    
        GestureDetector gestureDetector;
    
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (gestureDetector == null)
                gestureDetector =  new GestureDetector(_touchListenerService);
    
            _touchingView = view;
            boolean result = gestureDetector.onTouchEvent(motionEvent);
            _touchingView = null;
            return result;
        }
        // and some more code
    

    Since it is the same event handler, parent view catches onFling() event successfully while child view can set SingleTapUpHandler to process click event.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a scroll view with transparent background that covers most of the screen.
I have a View that contains a ParentModel, which contains 2 Models. I only
I've got a UITextview that covers the entire screen. To compensate for the keyboard
Let's say I have information in a table that is in the wrong database
I am beginner in rails. I have view that i try to print inside
I have a view that has a column to make it sortable. When clicking
I have a view that renders a list elements using the following template :
I have a view that shows user profile fields in a tabular format. There
I have a view that is used in a UINavigationController and and is automatically
I have a View that is basically setup like this: <Grid> <ViewBox> <Grid> <ItemsControl

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.