[英]Android. Webview. How to make element unclickable?
WebView is loading data from url . WebView正在从url加载数据。
wvBrowser.loadUrl(MainActivity.URL_ABOUT);
On WebViewClient's onPageStarted method I am trying to use javascript: 在WebViewClient的onPageStarted方法上,我尝试使用javascript:
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
String javascript = "javascript: "
+ "document.getElementById('logo').setAttribute(\"style\",\"pointer-events: none ;\");";
view.loadUrl(javascript);
}
Result: element is still clickable. 结果:元素仍可单击。
How to make only one element unclickable? 如何使仅一个元素不可点击?
webView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true; //True if the listener has consumed the event, false otherwise.
}
});
It will disable the webview touch event 它将禁用webview触摸事件
webView.setFocusableInTouchMode(false);
webView.setFocusable(false);
It will make the links non-focusable. 这将使链接无法集中。
Check this for more customization using javascript in android 选中此选项可在Android中使用JavaScript进行更多自定义
https://stackoverflow.com/a/4075955/3020568 https://stackoverflow.com/a/4075955/3020568
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.