zoom in phonegap for android

后端 未结 3 559
我寻月下人不归
我寻月下人不归 2020-12-11 03:08

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:

相关标签:
3条回答
  • 2020-12-11 03:28
    <meta name="viewport"  content="width=device-width, height=device-height, initial-scale=0.8, user-scalable=1" />
    

    That worked for me ;).

    It should be placed in the meta section of your html pages

    0 讨论(0)
  • 2020-12-11 03:36

    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

    0 讨论(0)
  • 2020-12-11 03:46

    Erks answer didn't worked for me (thought I wanted only to scale, no pinch zooming).

    But this worked: How to change PhoneGap's screen size?


    EDIT: It was long time ago since I played with this, so I will just copy-paste answer (just in case if for some reason stackoverflow decides to remove that link as stated in comment).

    I found a way to do that. I already had tried by using a meta viewport, but I guess I don't put everything that is necessary.

    Just put this meta tag below and everything should be fine.

    <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, target-densityDpi=device-dpi" />
    
    0 讨论(0)
提交回复
热议问题