1. Download our Official Android App: Forums for Android!

Apps WebView zoom out

Discussion in 'Android Development' started by canalrun, Jul 24, 2011.

  1. canalrun

    canalrun Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    10
    Joined:
    Oct 31, 2010

    Oct 31, 2010
    10
    0
    15
    Hello,
    I am using a WebView to display other's general webpages. Two questions:

    1. Using the on-screen zoom bar or the zoomin() and zoomout() methods in software, I am only able to zoom out one or two clicks before the zoom bar zoom out is grayed (disabled) or the zoomout() method no longer does anything.

    This is surprising. I would expect to be able to zoom out to the point of not being able to read the page anymore. Is this normal? What is limiting zoom out? is there a setMinimumScale() method?

    2. Is there a setScale() method of some sort? I see the setInitialScale() method which only seems to work when the page is first loaded, and I use getScale(). I don't see a way to set the scale.

    Thanks,
    Barry.
     

    Advertisement

  2. TheGraham

    TheGraham Member
    Rank:
    None
    Points:
    16
    Posts:
    47
    Joined:
    Jul 25, 2011

    Jul 25, 2011
    47
    2
    16
    double click the screen
     
  3. canalrun

    canalrun Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    10
    Joined:
    Oct 31, 2010

    Oct 31, 2010
    10
    0
    15
    Thanks for the reply, but nope.

    On both my Acer A500 (3.1) and Samsung Vibrant (2.2), with each of the several webpages I tried, the first double-click zooms in the page. The second double-click zooms out the page restoring it to the original size. Each subsequent set of double clicks repeats this behavior.

    What I would like to do is zoom out a page so that the entire page is visible, even though it may be too small to read.

    Something is limiting the amount I can zoom out. Zoom out once and the zoomOut() method stops working or the on-screen "-" button becomes grayed (disabled).

    Is there something I can do to enable the WebView to zoom out further?

    Thanks,
    Barry.
     
  4. alostpacket

    alostpacket Over Macho Grande?
    Rank:
    None
    Points:
    513
    Posts:
    7,972
    Joined:
    Nov 29, 2009

    Nov 29, 2009
    7,972
    3,603
    513
    Android App Developer
    NY
    Extend the WebView class and override the zoom methods.

    That's not an easy task at all, but you sound like a capable coder.

    If you havent already done this, you may want to find your way around the Android source code at kernel.org. Find the WebView class and see if there are methods you can override.

    Then insetead of using a WebView, use your own "SuperZoomWebView" or whatever you want to call it.

    In the layout XML, you just put the fully qualified classname as the name of the XML node.

    Also, I'm going to go ahead and move this to the app development forum :)


    Edit: also you may need to override onTouchEvent() And look for the double tap event to call your own zoom methods and not let the regular WebView class handle the event.
     

Share This Page

Loading...