Creating random colour in Java?
Here is a method for getting a random color: Benefits: Get the integer representation which can be used with java.awt.Color or android.graphics.Color Keep a static reference to Random .
Technical answers from my Stack Overflow history, with source links and licenses.
Showing 8 of 8 answers tagged colors
Exported May 9, 2026
Here is a method for getting a random color: Benefits: Get the integer representation which can be used with java.awt.Color or android.graphics.Color Keep a static reference to Random .
Going off the answer from @BlondeFurious , here is some Java code to get each hexadecimal value from 100% to 0% alpha: Output: A JavaScript version is below: You can also just Google "number to hex" where 'number' is...
Ted's answer to lighten a color wasn't working for me so here is a solution that might help someone else:
Here is a class I wrote. You can create your own material color palette or get a random color. Example uses: MaterialColorPalette.java Just copy the class into your project and add the package declaration.
You will need to use reflection to tint the select handles (bubbles). I wrote the following class this morning: Example usage: EditTextTint.java : Note: This should work from Jelly Bean to Nougat. However, since it uses...
ImageIO.read(file) should return a BufferedImage . You can also use PixelGrabber to get a specific color. Example: ToolkitImage also has a method to get the BufferedImage but may return null: Why does ToolkitImage...
You can use the following method to get a darker primary color: Example:
AppCompat resources can change in future updates. You should put a close button in your resources and use that drawable instead. If you want to make the current drawable white, then you can apply a ColorFilter ....