Android webview remove blue link border

丶灬走出姿态 提交于 2020-01-01 06:35:53

问题


When using webview in my application, everytime I click on a link a blue box highlights the text or image. Is there anyway of removing this feature from webview?


回答1:


For accessibility reasons you shouldn't just blanket set the tap highlight color to transparent.

For elements where you want full control:

1.) Remove the tap-highlight-color

.btn {
    ....

    -webkit-tap-highlight-color: transparent;
}

2.) Add a new :active state (in this example set a background color

.btn:active {
    background-color: rgba(100, 100, 100, 1.0);
}

3.) On some elements like you may see a blue or orange border, this is just to the focus state, to remove the border:

.btn {
    ....
    -webkit-tap-highlight-color: transparent;
    outline: 0;
}

4.) Add a :focus state

.btn:focus {
    background-color: rgba(200, 200, 200, 1.0);
}

5.) For bonus points add a :focus:active state

.btn:focus:active {
    background-color: rgba(150, 150, 150, 1.0);
}



回答2:


Didn't have 50 reputation to post a comment.
Blow is the main content from the link in above answer.

    * {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);  
    }

rgba() is just like rgb(), but it takes a 4th parameter for opacity.



来源:https://stackoverflow.com/questions/10138968/android-webview-remove-blue-link-border

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!