Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Android color issues on 6.x #12198

Closed
LukasPaczos opened this issue Jun 22, 2018 · 0 comments
Closed

Android color issues on 6.x #12198

LukasPaczos opened this issue Jun 22, 2018 · 0 comments
Labels
Android Mapbox Maps SDK for Android

Comments

@LukasPaczos
Copy link
Contributor

LukasPaczos commented Jun 22, 2018

Refs. mapbox/mapbox-navigation-android#1045.

As seen in mapbox/mapbox-navigation-android#1045, on v6.2.0 Android colors are being parsed incorrectly resulting in a black fill.

Also, on all v6.x versions, excluding v6.2.0, the Android colors that have modified alpha component are also parsed incorrectly where alpha is ignored and the color is treated as fully opaque (unless the alpha value is 0).

All above issues refer to Expression#color expression. The workaround is to always use Expression#rgb or Expressions#rgba, for example instead of

layer.setProperties(
  fillColor(
    interpolate(
      exponential(0.8f),
      zoom(),
      stop(1, color(Color.GREEN)),
      stop(4, color(Color.BLUE)),
      stop(12, color(ContextCompat.getColor(this, R.color.red_with_alpha))),
      stop(20, color(Color.BLACK))
    )
  )
);

you should use

layer.setProperties(
  fillColor(
    interpolate(
      exponential(0.8f),
      zoom(),
      stop(1, rgb(0, 255, 0)),
      stop(4, rgb(0, 0, 255)),
      stop(12, rgba(255, 0, 0, 0.25)),
      stop(20, rgb(0, 0, 0))
    )
  )
);

/cc @tobrun @Guardiola31337 @danesfeder @langsmith

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

No branches or pull requests

2 participants