如何防止 webview 中的缩放控件在放大或缩小后消失。
并且这些缩放控件总是在滑动 webview 后显示,即缩放控件不会在 webview 加载后立即自动显示。
我已经尝试过这段代码。
webview = (WebView)findViewById(R.id.webview);
//getWindow().requestFeature(Window.FEATURE_PROGRESS);
WebSettings webSettings = webview.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setLoadsImagesAutomatically(true);
webSettings.setSupportZoom(true) ;
webSettings.setBuiltInZoomControls(true);
// findViewById(R.id.LinearLayout01).;
webview.invokeZoomPicker();
最佳答案
最好的选择是实现 ZoomButtonsController。
class myClass implements ZoomButtonsController.OnZoomListener{
public ZoomButtonsController zoomy;
private WebView myWebView;
public myClass(){
zoomy = new ZoomButtonsController(this);
zoomy.setOnZoomListener(this);
zoomy.setZoomSpeed(500);
zoomy.setAutoDismiss(false);
}
@Override
public void onZoom(boolean zoomIn) {
if(zoomIn){
myWebView.zoomIn();
}else{
myWEbView.zoomOut();
}
}
public void toggleZoom(){
if(!zoomy.isVisible()){
zoomy.setVisible(true);
}else{
zoomy.setVisible(false);
}
}
}
希望这能让您朝着正确的方向前进。
关于Android webview缩放按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3758188/