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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:12:02+00:00 2026-06-11T04:12:02+00:00

I am showing a webpage in an Android WebView. The page needs to be

  • 0

I am showing a webpage in an Android WebView. The page needs to be scaled to fit the available width of the WebView.

HTML (width 550 is just an example, that could change):

<html> 
<head> 
<meta name="viewport" content="width=550">
...

Java:

mWebView = (WebView)findViewById(R.id.webView);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setHorizontalScrollBarEnabled(false);
mWebView.setVerticalScrollBarEnabled(false);
mWebView.requestFocus(View.FOCUS_DOWN);
mWebView.getSettings().setLoadWithOverviewMode(true); // required for scaling
mWebView.getSettings().setUseWideViewPort(true); // required for scaling
mWebView.loadUrl(someUrl);

This works fine, except one problem: double-tab triggers a switch between overview mode and default scale.
Is there any way to disable this functionality?

Btw: I cannot calculate the scale in the code, because the loaded pages might have different sizes, which I do not know beforehand. I also already checked the source code of WebView, but do not see anything, that I could override or change.

  • 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-11T04:12:04+00:00Added an answer on June 11, 2026 at 4:12 am

    You could write your own WebView implementation implemting OnGestureListener:

    public class MyWebView extends WebView implements OnGestureListener
    

    Inside declare a GestureDetector:

      private GestureDetector             gestureDetector;
    

    Implement a initWebView() method and call it in the constructor like this:

    // Best you do this for every WebViewConstructor:
      public AppWebView(Context context) {
      super(context);
      initWebView(); }
    
    private void initWebView(){
       gestureDetector = new GestureDetector(getContext(), this);
       // Do any other customizations for your webview if you like. 
    }
    

    Now implement the methods from OnGestureListener and return true on double tap events:

      public boolean onSingleTapConfirmed(MotionEvent e) {
        return false; //Nothing
      }
    
      public boolean onDoubleTap(MotionEvent e) {
        return true; //Nothing
      }
    
      public boolean onDoubleTapEvent(MotionEvent e) {
        return true; //Nothing
      }
    
      public boolean onDown(MotionEvent e) {
        return false; //Nothing
      }
    
      public void onShowPress(MotionEvent e) {
        //Nothing
      }
    
      public boolean onSingleTapUp(MotionEvent e) {
        return false; //Nothing
      }
    
      public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
        return false; //Nothing
      }
    
      public void onLongPress(MotionEvent e) {
        //Nothing
      }
    
      public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
        return false; //Nothing
      }
    

    Finally Override OnTouchEvent of your webview and let it pass through events to the gesture detector like this:

      @Override
      public boolean onTouchEvent(MotionEvent event) {
        if (gestureDetector.onTouchEvent(event)) return true;
        return super.onTouchEvent(event);
      }
    

    This works pretty good generally but there is 1 basic flaw to this solution: Some Events that are not identified as DoubleTap events could cause the Zoom of your webview.

    I´m still working on a solution for that and will post my progress here:
    WebView getting rid of double tap zoom.

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

Sidebar

Related Questions

I want to hide the cursor when showing a webpage that is meant to
I have a simple WebView-based activity that follows the Hello, WebView example to enable
I have created a webpage http://babysoftblog.co.cc/shahma/kmz/map_sexten.html in html5 with offline cache.its showing google map
I have a webpage that implements a set of tabs each showing different content.
I am showing Gravatar's Avatar on my webpage comments like that $hash = md5(trim($row['email']));
I'd like to put a calendar on a webpage showing which days a house
A web page of a web application was showing a strange error. I regressively
When showing data from a mysql table on an php page does it have
I've been looking at using a WebView to display an HTML5 webpage, where the
EXPLAINING WHAT I'M TRYING TO SOLVE: I have a webpage ( file_list.php ) showing

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.