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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:31:16+00:00 2026-06-03T05:31:16+00:00

I added a touch event to a linear layout to respond to swipe gestures,

  • 0

I added a touch event to a linear layout to respond to swipe gestures, and it works well. However, when i add buttons to the layout, the parent liner layout is ignored. How should I prevent this from happening?

LinearLayout ln2 = (LinearLayout) findViewById(R.id.fr2);
ln2.setOnTouchListener(swipe);

How to i use onInterceptTouch?

  • 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-03T05:31:18+00:00Added an answer on June 3, 2026 at 5:31 am

    You should create your own layout and override onInterceptTouchEvent(MotionEvent ev) method of your layout.

    For Example I created my own layout which extends RelativeLayout

           @Override
           public boolean onInterceptTouchEvent(MotionEvent ev) {
             return true; // With this i tell my layout to consume all the touch events from its childs
          }
    
        @Override
        public boolean onTouchEvent(MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
            // Log.d(TAG, String.format("ACTION_DOWN | x:%s y:%s", 
                break;
            case MotionEvent.ACTION_MOVE:
            //Log.d(TAG, String.format("ACTION_MOVE | x:%s y:%s", 
                break;
            case MotionEvent.ACTION_UP:
                break;
            }
            return true;
        }
    

    And when i put a button to my layout, even i clicked that button, My Layout consumes all the touchEvent because of the onInterceptTouchEvent always returns true.

    Hope this should help you

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

Sidebar

Related Questions

I have a touchesBegan: method which works fine. However I recently added a UIView
I added a custom validation method to validate a password. However, it does not
I added a batch (.bat) file to my project. I want to add a
On iPhone, iPod touch and (presumably) iPad, Apple has multi-touch event handling available via
I'm trying to fire a custom event in sencha touch, and it seems to
I added the controller's container to the layout. When I try to call the
i am using a uiview parent view....overidded touch began and touch ended methods... when
How could I track an event like touch on iPhone screen for 2 seconds.
I have a UITextField that responds to touch events when it is added as
In a Cocoa-Touch iPhone app, I get this error if I add a class

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.