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 8444837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:30:00+00:00 2026-06-10T09:30:00+00:00

I tried to understand how Android handle touch event and got a little bit

  • 0

I tried to understand how Android handle touch event and got a little bit confused. From what I understand touch event are send to the root view and pass down to the children.
I have a FrameLayout that is a container for Fragment.
First fragment view is a ScrollView, second one is some kind of Gallery (HorizontalListView) and the last one is also FrameLayout. Only one fragment in the layout each time.
What I want to do is to identify user swipes on the screen, for the app use. I want to count the swipes and do something after some number of swipes.

I tried to put a OnTouchListener on the top FrameLayout but it doesn’t get called when the child is the ScrollView or the Gallery. I tried to return false and also true in the end of onTouch, but I get same result – it’s never being called.

How can I do it?
I just want to “transparently” handle the touch events and passing them on like I didn’t even touch them.

  • 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-10T09:30:01+00:00Added an answer on June 10, 2026 at 9:30 am

    My understanding is that it actually goes the other direction. The Child views get their event triggered first (sort of). The root view get’s it’s dispatchTouchEvent() called, which propagates the event down to the children’s onTouchEvent(), and then, depending on whether they return true or false, the parent’s onTouchEvent() is called.

    The normal solution for intercepting things like this is to override dispatchTouchEvent(MotionEvent ev) in one’s activity like so:

    @Override
    public boolean dispatchTouchEvent (MotionEvent ev) {
      // Do your calcluations
      return super.dispatchTouchEvent(ev);
    }
    

    The documentation for this one is here. Note that you can also override that method in any ViewGroup (such as a FrameLayout, etc)

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

Sidebar

Related Questions

Tried examples from 'php.net' but don't understand what's the problem. Any suggestions? <?php $_SESSION['test']
I understand that Aptana is built from Eclipse. I tried searching for the Package
I just tried dynamodb example from amazon. I understand the advantages on the db
I do not understand Android layouts. I have the following structure and have tried
I have tried this project on both android and ios with little success. There
I tried to understand this line of code, but it is failed. $this->request->{self::FLAG_SHOW_CONFIG} ===
I've tried to understand some of the posts of similar, but don't quite understand
I have tried to understand AOP, Dependency Injection and Inversion of Control SPRING related
I tried to execute this query and i can´t understand what´s wrong with it.
I have tried my best to understand a very similar StackOverflow question , but

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.