我正在尝试在活动中显示一个弹出窗口。我的弹出窗口的布局只包含一个webview。显示弹出窗口,我可以在webview中显示内容。当我使用webview.setbuiltinzoomcontrols(true)
应用程序实现缩放时,当我尝试捏缩放时崩溃。代码如下所示
public void showImageInPopup(String cmImage){
final String imgSrc = cmImage;
Log.d("called IMage function", "called IMage function"+cmImage);
runOnUiThread(new Runnable() {
@Override
public void run() {
LayoutInflater searchPopupInflater = (LayoutInflater) getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
imagePopupView = searchPopupInflater.inflate(
R.layout.imageview_popup_layout, null);
int screenWidth;
int screenHeight;
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
screenWidth = metrics.widthPixels;
screenHeight = metrics.heightPixels;
imagePopupWindow = new PopupWindow(imagePopupView,
screenWidth/2, screenHeight/2 , true);
imagePopupWindow.setOutsideTouchable(false);
imagePopupWindow.setBackgroundDrawable(new BitmapDrawable());
imagePopupWindow.showAtLocation(topLayOut, Gravity.CENTER, 0, 0);
imageDisplayWebView = (WebView) imagePopupWindow.getContentView().findViewById(R.id.imageWebView);
imageDisplayWebView.loadUrl(imgSrc);
imageDisplayWebView.setWebViewClient(new WebViewClient());
imageDisplayWebView.setWebChromeClient(new WebChromeClient());
imageDisplayWebView.getSettings().setDomStorageEnabled(true);
imageDisplayWebView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
imageDisplayWebView.getSettings().setJavaScriptEnabled(true);
imageDisplayWebView.getSettings().setBuiltInZoomControls(true);
imageDisplayWebView.getSettings().setSupportZoom(true);
}
});
}
这个函数是从 javascript 调用的。请提供任何帮助。谢谢