Android 根据color id 获取颜色16进制值

来源:互联网 发布:仓储物流软件系统 编辑:程序博客网 时间:2024/06/05 17:31
public static String changeColor(int id){
        StringBuffer stringBuffer = new StringBuffer();
        int color = CommentManager.getInstance().getContext().getResources().getColor(id);

        stringBuffer.append("#");
        stringBuffer.append(Integer.toHexString(Color.alpha(color)));
        stringBuffer.append(Integer.toHexString(Color.red(color)));
        stringBuffer.append(Integer.toHexString(Color.green(color)));
        stringBuffer.append(Integer.toHexString(Color.blue(color)));
        return stringBuffer.toString();
    }
原创粉丝点击