Tag: hex hex

将RGBA值转换为hex颜色代码

我的应用程序中有一些滑块允许用户更改ARGB颜色,但我需要将这些值转换为hex值,如0xff000000,它是纯黑色。 这是我到目前为止: protected int toHex(Color col) { String as = pad(Integer.toHexString(col.getAlpha())); String rs = pad(Integer.toHexString(col.getRed())); String gs = pad(Integer.toHexString(col.getGreen())); String bs = pad(Integer.toHexString(col.getBlue())); String hex = “0x” + as + rs + gs + bs; return Integer.parseInt(hex, 16); } private static final String pad(String s) { return (s.length() == 1) ? “0” + s : […]