Android WebView se aleja después de cargar la página

I have an initialized WebView with the following code:

_webView.setWebViewClient(new WebViewClient() {
   public void onPageFinished(WebView view, String url) {
       while (view.zoomOut());

But this does not work. The WebView zooms out while loading. But when it is finished, it will zoom in.

Is there any other way to zoom out completely after a page (I use the WebView to display an image) is loaded?

preguntado el 02 de febrero de 12 a las 10:02

3 Respuestas

Prueba este fragmento de código:

public class WebViewSampleActivity extends Activity 
     WebView wb;
    private class HelloWebViewClient extends WebViewClient 
        public boolean shouldOverrideUrlLoading(WebView view, String url) 
            return false;
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) 
        wb.setWebViewClient(new HelloWebViewClient());

Espero que esto ayude.

Respondido 02 Feb 12, 14:02

Gracias, wb.getSettings().setLoadWithOverviewMode(true); me hizo el truco: D - kroegerama

You're welcome. It sure does, but you might also want to include wb.getSettings().setUseWideViewPort(true) along with it for better results. Anyway, I've included all essential settings in my code. Didn't want it to fail somewhere. :) BTW, thanks for accepting the answer :) - Fantasma

Yo uso .setUseWideViewPort(true) already. And now also the following ones: .setDefaultZoom(ZoomDensity.FAR); .setBuiltInZoomControls(true); .setLoadWithOverviewMode(true); These should provide the best results for my purpose. Thanks again =) - kroegerama

If I want the page loaded fit the screen width,but after that,if user want to zoom in the content it's too small to see it clearly.How we can free the Webview to do that? - Chine Gary

Don't do anything in onPageFinished() en su lugar usa webview.getSettings().setDefaultZoom(WebviewSetting.ZoomDensity.FAR);

Espero que esto ayude

Respondido 02 Feb 12, 15:02

These are the two most important commands when loading images:


Respondido 29 Oct 16, 07:10

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.