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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:23:24+00:00 2026-05-26T16:23:24+00:00

I have a project using a ViewPager which works correctly: I can page from

  • 0

I have a project using a ViewPager which works correctly:
I can page from view to view by flicking left and right.

On one page of the ViewPager, I have a custom view and I am trying to add below it another view (LinearLayout) that is touch sensitive and that will not “page” the ViewPager. Like this:

<LinearLayout >

    <myView />

    <LinearLayout> // The touch sensitive region
    </LinearLayout>

</LinearLayout>

After my view has been inflated and added to the ViewPager, I call setOnTouchListener() to attach a listener to the internal LinearLayout. The listener returns “true”.

Unfortunateley when I move horizontally in that view, I move to another page.
The events I get are:
ACTION_DOWN, ACTION_MOVE (n times) and finally ACTION_CANCEL. Although I stayed within the view.

It seems that the event has gone up the view hierarchy and processed by the ViewPager.

Is there a logical explanation to this behaviour ?

  • 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-05-26T16:23:24+00:00Added an answer on May 26, 2026 at 4:23 pm

    I have found a workaround by intercepting events at the Activity level, overriding dispatchTouchEvent().

    In there, I call super.dispatchTouchEvent() for processing all events unless the user is touching my touch sensitive view. I test if the user is on the correct page and at the right location. In that case I process the event myself.

    @Override
    public boolean dispatchTouchEvent (MotionEvent ev) {
    
    
        if ( pager.getCurrentPosition()!=0 ) { // Test ViewPager page
                super.dispatchTouchEvent(ev);
        }   
        else {
    
            int[] xy = new int[2];
            findViewById(R.id.myTouchControl).getLocationOnScreen(xy);
            int topOfView = xy[1];
    
            if ( ev.getY() > topOfView ) {
                // Custom processing
                ...
    
            } else {
                // Standard processing
                super.dispatchTouchEvent(ev);
            }
        }
        return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one project that is using ESAPI4PHP which is a port of OWASP's
I have a legacy project using Rails 2.3.5 but I can't find with which
I have a project using ASIHTTP to multi download files from a site when
I have a test project using MbUnit and TestDriven.Net. If I right-click on an
I have a project using WCF which was working fine, but I moved the
We have a project using LINQ to SQL, for which I need to rewrite
I have a project using DevExpress docking components, I create forms in run-time, which
I'm on a asp.net MVC 2 project and have a view that inherits from
I have a project using DevExpress 8.3 (2008.3) which I just recently upgraded to
So, we have a project using the Three20 Library from Facebook ( http://github.com/facebook/three20 ),

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.