How to change the color integer value to hex String on Android

Asked 1 years ago, Updated 1 years ago, 70 views

An integer value was generated in android.graphics.Color. The integer value is -16776961. I'd like to change this value to #RRGGBB format for hexString. How shall I do it?

For example, I want to change -16776961 to #0000FFYo

android color hex java string

2022-09-22 22:10

1 Answers

String hexColor = String.format("#%06X", (0xFFFFFF & intColor)); You can do it in this way. %06x assigns the RRGGBB value to zero in hexadecimal format with 6 digits.


2022-09-22 22:10

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.