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

  • Home
  • SEARCH
  • 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 6378269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:59:01+00:00 2026-05-25T01:59:01+00:00

I hope someone can help me. This has been driving me crazy for days.

  • 0

I hope someone can help me. This has been driving me crazy for days.

I am designing an application using webview that allows users to swipe to next screen and back to previous screen using

public boolean onFling(MotionEvent event1, MotionEvent event2, float velocityX, float velocityY)

I also want to enable the user to scroll from top to bottom of the screen if there is more content than can fit on the screen. So, I have in the main.xml file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="800px"
    android:background="#ffffff">
<ScrollView android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff">   
<WebView xmlns:android="http://schemas.android.com/apk/res/android"     
android:id="@+id/webview"     
android:scrollbars="vertical"
android:layout_width="fill_parent"     
android:layout_height="fill_parent"
android:background="#ffffff"/>
</ScrollView>
</LinearLayout>

Problem is scroll view is not working now. Before I had the gesturedetector, I was enabling swipe detection using javascript but the user had to be very accurate with their left-right and right-left swipe actions.

I think the issue lies with the code that allows the gestureDetector to work – thanks for the contributor who posted that:

public boolean onFling(MotionEvent event1, MotionEvent event2, float velocityX, float velocityY) {     
String url = findURL(); 
if (event1.getRawX() > event2.getRawX()) {   
if(isButtonScreen(url)==false){
//get next SCREEN to display
getNext(url);
}else{
}
} else { 
if(isButtonScreen(url)==false)
{
//get previous
getPrevious(url);
}else{
}
}   
return true;   
}

I think it says if the user swipes from right to left, then show the next page otherwise show the previous page.

What I would like is some more clarity, if user swipes from left to right within a certain degree, then show next page or if user swipes from right to left within a certain degree, then show previous page, otherwise, scroll up or scroll down.

Is this how I should do it? Or am I missing something fundamental and it should work some other obvious way?

Thanks

Sorry, posted my own response in the wrong place. So far, I have a check to see if it is a fling or a scroll as follows:

//check if it is a swipe or a scroll
            public String isSwipe(MotionEvent event1, MotionEvent event2){
                String swipeDirection = "";
                double X = event1.getRawX()-event2.getRawX();
                double Y = event1.getRawY()-event2.getRawY();
                double Z = Math.round(Math.sqrt(Math.pow(X,2)+Math.pow(Y,2))); //the distance - rounded - in pixels
                double r = Math.atan2(Y,X); //angle in radians (Cartesian system)
                double swipeAngle = Math.round(r*180/Math.PI); //angle in degrees
                if ( swipeAngle < 0 ) { swipeAngle =  360 - Math.abs(swipeAngle); }

                if ( (swipeAngle <= 45) && (swipeAngle >= 0) ) {
                    swipeDirection = "left";
                } else if ( (swipeAngle <= 360) && (swipeAngle >= 315) ) {
                    swipeDirection = "left";
                } else if ( (swipeAngle >= 135) && (swipeAngle <= 225) ) {
                    swipeDirection = "right";
                } else if ( (swipeAngle > 45) && (swipeAngle < 135) ) {
                    swipeDirection = "up";
                } else {
                    swipeDirection = "down";
                }

                return swipeDirection;
            }

Now I want to scrollDown and scrollUp smoothly. If anyone has a reliable answer, I would very much appreciate your comment.

and finally to scroll down I used:

scrollBy(0, 50);

once I was happy i was actually swiping down.

It is not as smooth as I would like so if anyone has any improvements on this I would be most happy.

public boolean onFling(MotionEvent event1, MotionEvent event2, float velocityX, float velocityY) {     
                String url = findURL(); 
                if (event1.getRawX() > event2.getRawX()) {   
                            if(isButtonScreen(url)==false){
                                //get next
                                //getNext(url);
                                show_toast("swipe left"+isSwipe(event1, event2));
                            }else{
                            }
                    } else { 
                        if(isButtonScreen(url)==false){
                            //get previous
                            //getPrevious(url);
                            String result = isSwipe(event1, event2);
                            show_toast("swipe right "+result);
                            if(result.equalsIgnoreCase("down")){
                                //screen height + 50;
                                scrollBy(0, 50);
                            }
                        }else{
                        }
                    }

                return true;   
            }
  • 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-25T01:59:01+00:00Added an answer on May 25, 2026 at 1:59 am

    If you want to use gestures, you should not use a ScrollView without creating your own customer implementation.

    If you must have gestures in a ScrollView, then you should create your own custom class implementing ScrollView and override onTouchEvent from View to do what you want.

    Hope this helps!

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

Sidebar

Related Questions

I hope someone can help... This issue has been discussed here and I have
I hope that someone can help me with this problem that I've been having
hope someone can help me on this as been stuck for hours. I am
I hope someone can help me with this, as I'm unable to find the
Hope someone can help me out with this problem I am having. I just
Hope someone can help i cant seem to get my head around this, i
I hope someone can help me here. I'm having trouble loading this variable. Right
I am having a JQuery/ASP issue that I hope someone can help me with.
I hope someone can offer any help!! I have web page that initiates a
Hi guys I hope someone can help me with this I´m really stuck although

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.