Convert int color value to Color String No Alpha - Android Graphics

Android examples for Graphics:Color Alpha

Description

Convert int color value to Color String No Alpha

Demo Code


//package com.java2s;
import android.graphics.Color;

public class Main {
    public static String toColorStringNoAlpha(int bgColor) {
        return "#" + hex2(Color.red(bgColor)) + hex2(Color.green(bgColor))
                + hex2(Color.blue(bgColor));
    }/*from   w w  w.  j  av  a 2  s.  c o m*/

    public static String hex2(int val) {
        String a = Integer.toHexString(val);
        if (a.length() < 2) {
            a = "0" + a;
        }
        return a;
    }
}

Related Tutorials