bha*_*ath 11 android zoom android-webview
是否可以删除缩放按钮
?它在我缩放WebView时显示.我需要没有这些按钮的变焦控制.我正在使用android 2.3.
我使用下面的代码,
WebView webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setBuiltInZoomControls(false);
webview.getSettings().setJavaScriptEnabled(true);
FrameLayout mContentView = (FrameLayout) getWindow().
getDecorView().findViewById(android.R.id.content);
final View zoom = webview.getZoomControls();
mContentView.addView(zoom, ZOOM_PARAMS);
zoom.setVisibility(View.GONE);
Run Code Online (Sandbox Code Playgroud)
Sha*_*wal 26
getSettings().setBuiltInZoomControls(false);
Run Code Online (Sandbox Code Playgroud)
使用上面的代码行删除缩放按钮.
在API> = 11时,您可以使用:
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
Run Code Online (Sandbox Code Playgroud)
更新:::如果你想放大/缩小没有缩放控件然后使用下面的代码(从这里复制)
public class Main extends Activity {
private WebView myWebView;
private static final FrameLayout.LayoutParams ZOOM_PARAMS =
new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
Gravity.BOTTOM);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
myWebView = (WebView)findViewById(R.id.webView);
FrameLayout mContentView = (FrameLayout) getWindow().
getDecorView().findViewById(android.R.id.content);
final View zoom = myWebView.getZoomControls();
mContentView.addView(zoom, ZOOM_PARAMS);
zoom.setVisibility(View.GONE);
myWebView.loadUrl("http://www.almondmendoza.com");
}
}
Run Code Online (Sandbox Code Playgroud)
zvz*_*zej 11
在AndroidManifest上更改此内容:
android:minSdkVersion="8"
Run Code Online (Sandbox Code Playgroud)
对此:
android:minSdkVersion="11"
Run Code Online (Sandbox Code Playgroud)
在Web视图设置中使用它:
getSettings().setBuiltInZoomControls(true);
getSettings().setDisplayZoomControls(false);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19154 次 |
| 最近记录: |