Android Question How to change button color in a webview HTML code

joop

Active Member
Licensed User
Longtime User
button01.png button02.png I am using a webview with a button ,and want to change the buttoncolor when pressed.
When I test this html file in firefox , the buttoncolor changes in red when pressed.
With a WebView ,the buttoncolor stays blue ,it should be red when pressed (knop-class),
the center class is ok.

I don't think this is something in B4a but maybe someone has a clue.



The html code is :

HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style>

.knop {
    font-family: Calibri, sans-serif;
    font-size:13px;
    font-weight: bold;
    width: 160px;
    height: 25px;
    background:grey;
    color: white
}  

.knop:active {
   color: white;
   background:red;
}

.center {
    text-align: center;
    color: red;
}
  
</style>
</head>
<body style="border: 2mm solid rgb(238, 232, 170); background-color: white;float:left;">

<p class="center">Red and center</p> <br> <br>
 
<input type="button" class="knop" value="Geluid" />
 
 
<br> <br> <br> <br> <br> <br>
 

</body>
</html>




button02.png button02.png
button01.png
 

joop

Active Member
Licensed User
Longtime User
Thanks for this link Erel , a solution they mentioned

just add empty touchstart event to the body tag:
<bodyontouchstart="">


works,now the button color changes to red also with WebView.
 
Upvote 0
Top