我有显示协议内容的自定义webview对话框。内容来自网络服务。它没有任何问题我的手机(三星Galaxy S4,5.0.1)
但是当我尝试不同的手机时,我意识到了一个奇怪的问题。
-Sony Z5 6.0
-Nexus 5 6.0
-General Mobile Android One 7.0
这些设备拥有纯粹且几乎纯粹的6.0及以上Android操作系统,所以看起来像Android问题。在我测试的三星或华硕设备上不会出现此问题。
我的问题是webwiew(不是对话框,只有webview)的内容被淹没了两次,其中一个绘图位于整个屏幕区域的左下角,甚至覆盖了导航栏。内容有意模糊:)
DIALOG HELPER CLASS
public static void showWebviewDialog(final Context context, DialogModel model, final DialogCallback callback) {
//Initialise Dialog
dialog = new Dialog(context);
dialog.getWindow().getAttributes().windowAnimations = R.style.PauseDialogAnimation;
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_sozlesme);
dialog.setCanceledOnTouchOutside(false);
//Seting Data and callback ops
...
//
webViewDialog.getSettings().setJavaScriptEnabled(true);
webViewDialog.setHapticFeedbackEnabled(true);
webViewDialog.getSettings().setSupportZoom(true);
final String htmlContent = model.getTvDesc();
final String start = "<html><head><meta name=\"viewport\" content=\"user-scalable=no\"/><meta http-equiv='Content-Type' content='text/html' charset='UTF-8' /><style>p {color:#707A8F;}\nimg.size-full{width:100%; height:auto;} iframe{width:100%; height:auto;} img{display: inline; height: auto; max-width: 100%;}</style></head><body>";
final String end = "</body></html>";
//Show Dialog
dialog.setOnShowListener(new OnShowListener() {
@Override
public void onShow(DialogInterface dialogInterface) {
webViewDialog.loadDataWithBaseURL(null, start + htmlContent + end, null, "text/html; charset=UTF-8", null);
webViewDialog.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return super.shouldOverrideUrlLoading(view, url);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
pbSozlesmeDialog.setVisibility(View.GONE);
pbSozlesmeDialog.setIndeterminate(false);
}
});
}
});
dialog.show();
}
我的活动
DialogHelper.showWebviewDialog(ActivityXX.this, dialogModel, dialogCallback);