I have a problem with JellyBean, since whenever I navigate using the keyboard, it automatically focuses my html element of the hyperlink and input. It creates a blue highlight that I cannot hide with css.
* { -webkit-tap-highlight-color: rgba(0, 0, 0, 0); }
Even I set z-index: -1 for each html element to turn off focus, but JellyBean still autofocuses each of them when navigating the keyboard.
Here is my html code:
<html> <head> <title></title> </head> <body> <a tabIndex="-1" href="http://www.yahoo.com">yahoo</a> <a tabIndex="-1" href="http://www.google.com">google</a> <a tabIndex="-1" href="http://www.msn.com">msn</a><br/> <input type="button" name="" tabIndex="-1" value="yahoo"> <input type="button" name="" tabIndex="-1" value="google"> <input type="button" name="" tabIndex="-1" value="msn"> </body> </html>
Here is my webview configuration:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/mainLayout" android:layout_width="match_parent" android:layout_height="match_parent" > <WebView android:id="@+id/webView" android:layout_width="match_parent" android:layout_height="match_parent" android:focusable="false" /> </RelativeLayout>
Here is my activity:
package com.example.tony; import android.annotation.TargetApi; import android.app.Activity; import android.os.Bundle; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; public class WebActivity extends Activity { private WebView mainWebView; private WebSettings webSettings; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.web_view); mainWebView = (WebView) findViewById(R.id.webView); webSettings = mainWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setPluginState(WebSettings.PluginState.ON); mainWebView.setWebChromeClient(new WebChromeClient()); mainWebView.setScrollBarStyle(WebView.SCROLLBAR_POSITION_DEFAULT); mainWebView.loadUrl("http://192.168.2.145/test/nav.html"); } @TargetApi(16) public void setURL(){ webSettings.setAllowUniversalAccessFromFileURLs(true); } }
Tested with Nexus 7 and another jelly device. Is there a solution that I can turn off, focus on the html element level or turn off auto focus on the keyboard?
source share