argb Color To Hex - Android Graphics

Android examples for Graphics:Color

Description

argb Color To Hex

Demo Code


//package com.java2s;

public class Main {
    final public static String argbColorToHex(int alpha, int red,
            int green, int blue) {
        StringBuilder builder = new StringBuilder();
        builder.append(encodeToHex(alpha));
        builder.append(encodeToHex(red));
        builder.append(encodeToHex(green));
        builder.append(encodeToHex(blue));
        return builder.toString();
    }//  w  w w .  j  av a  2s. c o  m

    final public static String encodeToHex(int color) {
        StringBuilder builder = new StringBuilder();
        if ((color & 0xFF) < 0x10) {
            builder.append("0");
        }
        builder.append(Long.toHexString(color));
        return builder.toString();
    }
}

Related Tutorials