1

I have an app with a webview. I want to make the onclick highlight transparent.

setLightTouchEnabled(false); is deprecated now. Are there any alternatives?

I tried adding the -webkit-tap-highlight-color: rgba(0, 0, 0, 0); in the css, without any luck.

A link to an image that illustrates the issue:

Button onclick highlight

LaPriWa
  • 1,787
  • 1
  • 12
  • 19
Affen2
  • 11
  • 2
  • Which device you are using ?.In some devices -webkit-tap-highlight-color: rgba(0, 0, 0, 0); does not work.Try -webkit-tap-highlight-color: transparent; – Aravindraj Mar 31 '17 at 08:56
  • I'm currently testing on a Sony Xperia tablet. I saw a comment about rgba not working on Samsung, and it's not on Sony either. Using transparent instead of rgba doesn't make a difference, unfortunately. – Affen2 Mar 31 '17 at 09:22

1 Answers1

0

Option 1:

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


Webview.getSettings().setLightTouchEnabled(true);

or Option 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; 
    }
}); 
Saurav Prakash
  • 588
  • 1
  • 5
  • 26
  • Thank you for the input. However, I can't get any of the options to solve the issue. Option 1 is deprecated. Neither of them makes a difference. – Affen2 Mar 31 '17 at 09:51
  • http://stackoverflow.com/questions/2941900/is-it-wrong-to-use-deprecated-methods-or-classes-in-java /// you can use deprecated methods if it works fine – Saurav Prakash Mar 31 '17 at 09:57