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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:41:40+00:00 2026-05-30T22:41:40+00:00

edited for clarity I feel like this question already has an answer, but I

  • 0
  • edited for clarity

I feel like this question already has an answer, but I can’t find one.

I have a ScrollView in my layout, and it contains a variety of clickable views.

Under a specific condition I would like to disable clicks and events for the ScrollView and ALL of its children.

The following have not been helpful:

ScrollView.setEnabled(false)
ScrollView.setClickable(false)
ScrollView.setOnTouchListener(null)

As well as:

(parent view of the ScrollView).requestDisallowInterceptTouchEvent()

I have created a custom ScrollView with the following code:

public class StoppableScrollView extends ScrollView
{
    private static boolean stopped = false;

    public StoppableScrollView(Context context)
    {
        super(context);
    }

    public StoppableScrollView(Context context, AttributeSet attrs)
    {
        super(context, attrs);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev)
    {
        if(stopped)
        {
            return true;
        }
        else
        {
            super.onInterceptTouchEvent(ev);
            return false;
        }
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev)
    {
        if(stopped)
        {
            return true;
        }
        else
        {
            super.onTouchEvent(ev);
            return false;
        }
    }

    public static void setStopped(boolean inBool)
    {
        stopped = inBool;
    }

    public static boolean getStopped()
    {
        return stopped;
    }
}

Using only onTouchEvent() will stop the scrolling, but not the clicking of child views.

Using only onInterceptTouchEvent() makes it such that when clicks work scrolling does not, and vice versa.

Using both onTouchEvent() and onInterceptTouchEvent() successfully stops unwanted clicks on child views when stopped is ‘true’ but it also disables scrolling regardless of the state of stopped.

Is there an easier way to get this behaviour, or is there a way to modify the StoppableScrollView class so that it will handle these touch events properly?

  • 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-30T22:41:42+00:00Added an answer on May 30, 2026 at 10:41 pm

    What probably should help is the following (because I had similar problems):

    In the ScrollView you should do a RelativeLayout as Main Child (ScrollView does accept only 1 main child anyway). This RelativeLayout should of course of fill_parent in both directions.

    At the really end of the RelativeLayout (after all other children), you could put now a LinearLayout with transparent background (#00FFFFFF) which has also fill_parent in both directions. This LinearLayout should have Visibility = View.GONE (by default)
    Also you have to attach an empty OnClickListener to it. Now, because of zOrder if you make this LinearLayout Visibility = View.Visible it will catch all the events and avoid clicking the children above!

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

Sidebar

Related Questions

--edited for clarity (hopefully) I have an XML file that looks something like this:
Edited to Add * I haven't found a solution for this one yet, can
EDITED for clarity: I have 2 ListView i my application. The first one contains
(I've edited this for clarity, and changed the actual question a bit based on
Question edited for clarity I make an AJAX call, using the $.getJSON() method, and
Edited Question: This should be clear. using System; namespace UpdateDateTimeFields { class Program {
Edited: SOLUTION FOUND. This is strange and not the best solution, but I just
This is probably a completely stupid question, but i'm pretty new at objective-C and
I have such query (generated by Hibernate - edited for more clarity - below
I realize this is kind of a long question, but I saw no other

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.