Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebView: Different css interpretation depending on the Android API version

I am using that simple CSS in an Android WebView.

.rounded{
  text-align: center;
  border-radius: 25px;
  border: 2px solid #FFFF014F;
}

It is working totally OK with an API 28 device. But with a 22 API device I am not getting the same result (The border is not being shown at all).

These are the two devices I am using (Both devices have the same resolution):

enter image description here

I suppose the css properties are being interpreted different depeding on the WebView or API version. (I am not sure about that)

I would like to have one single css file working the same way all over the Android versions. So:

  • Is there a way to correct that?
  • Is there a documentation where I could find what css properties I can use depending on the API version?
like image 980
Alfonso_MA Avatar asked Mar 13 '20 23:03

Alfonso_MA


1 Answers

Use rgba() color notation. It's supported better than HEX rgba.

Let's convert #FFFF014F :

Red: FF = 255
Green: FF = 255
Blue: 01 = 1
Alpha: 4F = 79/255 = .31

So the result is border: 2px solid rgba(255, 255, 1, .31);

body {background:navy}

span {
  display:inline-block;
  padding:.5em;
  margin:1em;
  text-align: center;
  border-radius: 25px;
  color:#fff;
}

.hex {border: 2px solid #FFFF014F}
.rgba {border: 2px solid rgba(255, 255, 1, .31)}
<span class="hex">#FFFF014F</span>
<span class="rgba">rgba(255, 255, 1, .31)</span>
like image 96
Kosh Avatar answered Oct 06 '22 00:10

Kosh