에서 생성 된 정수가 있습니다. android.graphics.Color
정수 값은 -16776961입니다.
이 값을 #RRGGBB 형식의 16 진 문자열로 변환하는 방법
간단히 말하면 : -16776961에서 # 0000FF를 출력하고 싶습니다.
답변
이 마스크를 사용하면 RRGGBB 만 얻을 수 있으며 % 06X는 0으로 채워진 16 진수 (항상 6 자 길이)를 제공합니다.
String hexColor = String.format("#%06X", (0xFFFFFF & intColor));답변
Integer.toHexString ()을 사용해보십시오
답변
나는 대답을 찾았다 고 생각합니다.이 코드는 정수를 16 진수 문자열로 변환하고 알파를 제거합니다.
Integer intColor = -16895234;
String hexColor = "#" + Integer.toHexString(intColor).substring(2);참고 확실 알파를 제거하면 아무 영향을 미치지 않을 것이라고 경우에만이 코드를 사용합니다.
답변
여기 내가 한 일이 있습니다.
 int color=//your color
 Integer.toHexString(color).toUpperCase();//upercase with alpha
 Integer.toHexString(color).toUpperCase().substring(2);// uppercase without alpha고마워 당신이 일을 했어
답변
ARGB 색상의 정수 값을 16 진수 문자열로 :
String hex = Integer.toHexString(color); // example for green color FF00FF0016 진수 문자열을 ARGB 색상의 정수 값으로 :
int color = (Integer.parseInt( hex.substring( 0,2 ), 16) << 24) + Integer.parseInt( hex.substring( 2 ), 16);답변
이 메소드 Integer.toHexString을 사용하면 Color.parseColor를 사용할 때 일부 색상에 대해 알 수없는 색상 예외가있을 수 있습니다.
그리고이 메서드 String.format ( “# % 06X”, (0xFFFFFF & intColor)) 을 사용하면 알파 값이 손실됩니다.
따라서이 방법을 권장합니다.
public static String ColorToHex(int color) {
        int alpha = android.graphics.Color.alpha(color);
        int blue = android.graphics.Color.blue(color);
        int green = android.graphics.Color.green(color);
        int red = android.graphics.Color.red(color);
        String alphaHex = To00Hex(alpha);
        String blueHex = To00Hex(blue);
        String greenHex = To00Hex(green);
        String redHex = To00Hex(red);
        // hexBinary value: aabbggrr
        StringBuilder str = new StringBuilder("#");
        str.append(alphaHex);
        str.append(blueHex);
        str.append(greenHex);
        str.append(redHex );
        return str.toString();
    }
    private static String To00Hex(int value) {
        String hex = "00".concat(Integer.toHexString(value));
        return hex.substring(hex.length()-2, hex.length());
    }답변
String int2string = Integer.toHexString(INTEGERColor); //to ARGB
String HtmlColor = "#"+ int2string.substring(int2string.length() - 6, int2string.length()); // a stupid way to append your color