提供一段简便的代码,将十进制的RGB(一般我是用截图ctr+alt+A显示的那个RGB),转换为android的xml文件中描述颜色的十六进制(记得在前面加上#号)
public class ColorParse { public static void toHex(int r, int g, int b){ String hr = Integer.toHexString(r); String hg = Integer.toHexString(g); String hb = Integer.toHexString(b); System.out.println(hr + hg + hb); } public static void main(String[] args) { toHex(136, 136, 136); } }
替换main中toHex的三个参数,运行就能得到十六进制的字符串了
很简单~希望你喜欢
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/212016.html原文链接:https://javaforall.net
