简体   繁体   English

setLightTouchEnabled(假); 不推荐使用-替代?

[英]setLightTouchEnabled(false); deprecated - alternative?

I have an app with a webview. 我有一个带有网络视图的应用程序。 I want to make the onclick highlight transparent. 我想使onclick高亮透明。

setLightTouchEnabled(false); is deprecated now. 现在已弃用。 Are there any alternatives? 还有其他选择吗?

I tried adding the -webkit-tap-highlight-color: rgba(0, 0, 0, 0) ; 我尝试添加-webkit-tap-highlight-color: rgba(0, 0, 0, 0) ; in the css, without any luck. 在CSS中,没有任何运气。

A link to an image that illustrates the issue: 指向说明问题的图像的链接:

Button onclick highlight 按钮onclick高亮

Option 1: 选项1:

Webview.requestFocus(View.FOCUS_DOWN|View.FOCUS_UP);


Webview.getSettings().setLightTouchEnabled(true);

or Option 2: 或选项2:

mWebView.setOnTouchListener(new View.OnTouchListener() { 
@Override
public boolean onTouch(View v, MotionEvent event) {
       switch (event.getAction()) { 
           case MotionEvent.ACTION_DOWN: 
           case MotionEvent.ACTION_UP: 
               if (!v.hasFocus()) { 
                   v.requestFocus(); 
               } 
               break; 
       } 
       return false; 
    }
}); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM