Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zoom in phonegap for android

How do I enable zoom on my phonegap app for android users?

I tried to customize "Sample/src/com/phonegap/Sample/Sample.java" but it still just doesn't work:

Any ideas?

package com.phonegap.Sample;

import android.app.Activity;
import android.os.Bundle;
import com.phonegap.*;
import android.webkit.WebSettings;

public class Sample extends DroidGap
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {


        super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index.html");

        WebSettings ws = super.appView.getSettings();
        ws.setSupportZoom(true);
        ws.setBuiltInZoomControls(true); 

    }
}
like image 482
costi Avatar asked Jan 12 '11 11:01

costi


1 Answers

This has worked for me, the above solution didn't.

package com.my.app;

import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebSettings.ZoomDensity;

import com.phonegap.*;

public class MyDroidActivity extends DroidGap {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index.html");
        WebSettings settings = appView.getSettings();
        settings.setBuiltInZoomControls(false);
        settings.setSupportZoom(false);
        settings.setDefaultZoom(ZoomDensity.FAR);
    }
}

This is where I found it, the credit goes to them! https://github.com/phonegap/phonegap-android/issues/120

like image 135
Kieran Goodary Avatar answered Sep 20 '22 13:09

Kieran Goodary