7

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?
1
  • 1
    Have you checked that devices using API 22 can support the 8-digit representation for color? For example caniuse.com/#feat=css-rrggbbaa read the notes at the bottom and also please check this bugs.chromium.org/p/chromium/issues/detail?id=618472 and go for @Kosh answer which is most probably more fail-safe over API versions. Commented Mar 22, 2020 at 18:42

1 Answer 1

3
+25

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>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.