← all tools

Colour ↔ Kotlin Int

Why your red is -65536. Convert between hex, ARGB, and the signed 32-bit integer Android actually stores.

convert androidcolourkotlinint

Accepts #FF0000, 0xFFFF0000, -65536, rgb(255, 0, 0) — or just the number your debugger showed you. It works out which one you meant.

Every representation
  

Android packs colour into a signed 32-bit Int. That means opaque red (#FF0000) is -65536 in the debugger, and opaque black is -16777216 rather than 0. Nothing is broken — the top bit is alpha, and it makes the number negative. This converts in both directions and shows every representation at once, so you can paste the value you have and get the one you need.