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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:28:44+00:00 2026-05-25T09:28:44+00:00

I have a custom view which I wish to handle touch events for. In

  • 0

I have a custom view which I wish to handle touch events for. In particular, dragging a finger over the view should cause its contents to scroll. To do this, I have implemented the following onTouchListener:

private OnTouchListener graphOnTouchListener = new OnTouchListener() {
    public boolean onTouch(View v, MotionEvent event) {
        System.out.println("onTouch called");
        System.out.println("view width: " + v.getWidth());
        System.out.println("view height: " + v.getHeight());
        System.out.println("view: " + v);

        switch (event.getAction() & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_DOWN:
                // First finger down
                System.out.println("ACTION_DOWN x: " + event.getX() + ", y: " + event.getY());
                startTouch(event.getX());
                break;
            case MotionEvent.ACTION_UP:
                // Last finger to be removed
                System.out.println("ACTION_UP x: " + event.getX() + ", y: " + event.getY());
                break;
            case MotionEvent.ACTION_MOVE:
                // A finger moves
                System.out.println("ACTION_MOVE x: " + event.getX() + ", y: " + event.getY());
                moveTouch(event.getX());
                break;
            default:
                break;
        }  

        // The event has been handled, so return true
        return true;
    }
};

This works as expected, unless the user moves their finger up or down while on the view. At this point, touch events stop being sent (as evidenced by a lack of output in LogCat). However, using adb shell getevent still shows events being generated by touch movement.

Can anyone suggest how I can rectify this?

As requested, the layout XML looks like:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="#ffffff">
    <FrameLayout android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <ScrollView android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:padding="10dip">
            <LinearLayout android:layout_width="fill_parent"
                android:layout_height="fill_parent" android:orientation="vertical">
                <com.graphlib.ShaderAreaGraphView
                    android:layout_width="fill_parent" android:layout_height="200dip"
                    android:id="@+id/activity_power_realtime" android:background="#000000" />
                <LinearLayout android:layout_width="fill_parent" android:id="@+id/linearLayout1" android:layout_height="wrap_content" android:gravity="center">
                    <Button android:text="&lt;&lt;" android:id="@+id/goBackwardsButton" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
                    <Button android:text="Zoom out" android:id="@+id/zoomOutButton" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
                    <Button android:text="Zoom in" android:id="@+id/zoomInButton" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>
                    <Button android:text="&gt;&gt;" android:id="@+id/goForwardsButton" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
                </LinearLayout>
            </LinearLayout>
        </ScrollView>
    </FrameLayout>
</LinearLayout>
  • 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-25T09:28:44+00:00Added an answer on May 25, 2026 at 9:28 am

    It turns out the issue is that the view is contained in a ScrollView. Removing the ScrollView fixes the problem.

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

Sidebar

Related Questions

I have a custom toolbar view which I'm storing in its own nib file.
I have a custom view class, which receives the mouse events. I do not
I have a custom Android view which overrides onTouchEvent(MotionEvent) to handle horizontal scrolling of
I have a custom view which has a piano keyboard drawn inside of it.
Please help me to turn off user interaction. I have a custom view which
In my custom View which I have added to my viewControllers's view, I need
I have two helper methods inside a custom View which are called by their
I have a view with two subviews: A UIImageView A small Custom View which
I have a custom view with several NSTextField controls for which I want to
I have a GridView in which each row has a custom view. The grid

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.