2012-07-11 57 views
0

我有一个webview缩放范围的问题。这是我的代码web视图:webView和缩放范围

WebView web = new WebView(getContext()); 
web.getSettings().setJavaScriptEnabled(true); 
web.getSettings().setBuiltInZoomControls(true); 

String imagePath = id; 
String html = "<html><body style='margin:0;padding:0;'><img src=\""+ imagePath + "\" height=\""+ height + "\"width=\""+ width+ "\"></body></html>"; 
web.loadDataWithBaseURL("file:///mnt/sdcard/DinEgen/", html, "text/html","utf-8",""); 
web.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); 
web.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR); 
web.clearView(); 
web.clearCache(true); 

我想知道这是可以做到的,当我启动应用程序,我只能放大,当我回来,我只能从开始缩小尺寸。 这是放大:enter image description here

这是可以阻止缩小? 我想避免缩小以这个规模:enter image description here

回答

4

是的,你可以停止变焦,并通过添加下面的行HTML的标题适应这的屏幕尺寸:

<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1" />