Java tutorial
//package com.java2s; //License from project: Apache License public class Main { /** * @param originalColor color, without alpha * @param alpha from 0.0 to 1.0 * @return */ public static String addAlpha(String originalColor, double alpha) { long alphaFixed = Math.round(alpha * 255); String alphaHex = Long.toHexString(alphaFixed); if (alphaHex.length() == 1) { alphaHex = "0" + alphaHex; } originalColor = originalColor.replace("#", "#" + alphaHex); return originalColor; } }