參考資料1:zoom in phonegap for android
Step 1.在android程式碼先import WebSettings
import android.webkit.WebSettings;
import android.webkit.WebSettings.ZoomDensity;
Step 2. super.loadUrl之後加上
WebSettings settings = appView.getSettings();
settings.setBuiltInZoomControls(true);
settings.setSupportZoom(true);
settings.setDefaultZoom(ZoomDensity.MEDIUM);
android程式碼改完如下:
....
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.htm");
WebSettings settings = appView.getSettings();
settings.setBuiltInZoomControls(true);
settings.setSupportZoom(true);
settings.setDefaultZoom(ZoomDensity.MEDIUM);
}
....
Step 3.開啟htm檔,並修改meta標籤的viewport,改成如下:
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1,user-scalable=1">
P.S注意,如果使用JQuery Mobile在html檔中的<div data-role="header" >或<div data-role="footer" >,不能有data-position="fixed"屬性值,否則無法縮放
沒有留言:
張貼留言