把一个Color转为html里所用的颜色代码

来源:互联网 发布:社交网络结尾视频 编辑:程序博客网 时间:2024/06/05 15:21

public String getColorCode(Color color) {String string;return "#" + ((string = Integer.toHexString(color.getRed())).length() == 2 ? string : ("0" + string))+ ((string = Integer.toHexString(color.getGreen())).length() == 2 ? string : ("0" + string))+ ((string = Integer.toHexString(color.getBlue())).length() == 2 ? string : ("0" + string));}

可能以后用得上。



0 0
原创粉丝点击