Alfonso_MA
Alfonso_MA

Reputation: 555

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:

Upvotes: 7

Views: 307

Answers (1)

Kosh
Kosh

Reputation: 18413

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>

Upvotes: 3

Related Questions