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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:49:42+00:00 2026-06-16T04:49:42+00:00

I set the onFling() event of Gesture on ScrollView , but it is not

  • 0

I set the onFling() event of Gesture on ScrollView, but it is not working on ScrollView,

package com.doubletap;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.GestureDetector;
import android.view.GestureDetector.OnDoubleTapListener;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;
import android.widget.TextView;

public class DoubleTapActivity extends Activity implements OnGestureListener 
{
private GestureDetector gd;

private TextView tvTap;

String TAG = getClass().getSimpleName();

private static final int SWIPE_MIN_DISTANCE = 120;
private static final int SWIPE_MAX_OFF_PATH = 250;
private static final int SWIPE_THRESHOLD_VELOCITY = 200;

@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    tvTap = (TextView)findViewById(R.id.tvTap);

    gd = new GestureDetector(this);

    gd.setOnDoubleTapListener(new OnDoubleTapListener()
    {
        @Override
        public boolean onDoubleTap(MotionEvent e) 
        {
            return false;
        }

        @Override
        public boolean onDoubleTapEvent(MotionEvent e) 
        {
            return false;
        }

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) 
        {
            return false;
        }
    });
}

@Override
public boolean onTouchEvent(MotionEvent event) 
{
    return gd.onTouchEvent(event);//return the double tap events
}

@Override
public boolean onDown(MotionEvent e) 
{
    return false;
}

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) 
{

    try {
        if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH)
        {
             return false;
        }

        if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
             tvTap.setText("Flip Right to Left");
             Log.v(TAG, "Right to Left");
        }  else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
            tvTap.setText("Flip Left to Right");
             Log.v(TAG, "Left to Right");
        }
    } catch (Exception e)
    {

    }
    return false;
}

@Override
public void onLongPress(MotionEvent e) 
{
}

@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) 
{
    return false;
}

@Override
public void onShowPress(MotionEvent e) 
{
}

@Override
public boolean onSingleTapUp(MotionEvent e) 
{
    return false;
}
}

main.xml

<?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">
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:text="@string/hello"
    android:textStyle="bold" />
<TextView
    android:id="@+id/tvTap"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dip" >
</TextView>
<TextView
    android:id="@+id/tvTapEvent"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dip" >
</TextView>
<ScrollView
    android:id="@+id/scroll"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >
        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Button1" />
        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Button2" />
        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Button3" />
        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Button4" />
        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Button5" />
        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Button6" />
        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Button7" />
        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Button8" />
        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Button9" />
        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Button10" />
    </LinearLayout>
</ScrollView>

does anybody know how to implement the onFling() event on Scrollview ??

  • 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-16T04:49:43+00:00Added an answer on June 16, 2026 at 4:49 am

    This works for me. Hopefully you can add your double tap actions in here.

        public class ScrollViewFling extends Activity 
    {
        private GestureDetector mGesture;
    
        @Override
        public void onCreate(Bundle savedInstanceState) 
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.scrollviewfling);
            mGesture = new GestureDetector(this, mOnGesture);
    
        }
        @Override
        public boolean dispatchTouchEvent(MotionEvent ev) {
            boolean handled = super.dispatchTouchEvent(ev);
            handled = mGesture.onTouchEvent(ev);    
            return handled;
        }
    
        private OnGestureListener mOnGesture = new GestureDetector.SimpleOnGestureListener() {
    
            @Override
            public boolean onDown(MotionEvent e) {
                return false;
            }
    
            @Override
            public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                Log.v("fling", "Flinged.");
                return true;
            }
    
            @Override
            public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
                return false;
            }
        };
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get fling gesture detection working in my Android application. What I
Set a button's background is not as simple as android's dev.it's more complex; in
I set a click listener on a ViewPager , but the onClick event is
set batVar_Parameters=/Developer /Test=0 if not '%batVar_Iteration%' equ '-1' ( set batVar_Parameters=%batVar_Parameters% /Iteration=%batVar_Iteration% ) if
Set up and Explanation : I'm working on a project for school, and have
set A=2 && echo %A% This does not echo A as 2 in windows.
Set oXMLHttp=Server.CreateObject(MSXML2.XMLHTTP) On Error Resume Next oXMLHttp.open GET, http://xxxxxx.com,False oXMLHttp.setRequestHeader Content-Type, application/x-www-form-urlencoded oXMLHttp.send() x
set RF_PROPERTIES=%ARCOT_HOME%\conf dir %RF_PROPERTIES% if not exist %RF_PROPERTIES% goto NO_RF_PROPERTIES The ARCOT_HOME variable above
I set a image as Button backgroud,but Button has no highlight when click it.
I'm implementing a onFling detector much like the following question: Fling gesture detection on

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.