[英]Android. Webview. How to make element unclickable?
WebView正在從url加載數據。
wvBrowser.loadUrl(MainActivity.URL_ABOUT);
在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);
}
結果:元素仍可單擊。
如何使僅一個元素不可點擊?
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.
}
});
它將禁用webview觸摸事件
webView.setFocusableInTouchMode(false);
webView.setFocusable(false);
這將使鏈接無法集中。
選中此選項可在Android中使用JavaScript進行更多自定義
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.