/**
* 获取十六进制颜色值
*
* @param context
* @param id
* @return
*/
public static String changeColor(Context context, int id) {
StringBuffer stringBuffer = new StringBuffer();
int color = context.getResources().getColor(id);
String R = Integer.toHexString(Color.red(color));
String G = Integer.toHexString(Color.green(color));
String B = Integer.toHexString(Color.blue(color));
R = R.length() == 1 ? "0" + R : R;
G = G.length() == 1 ? "0" + G : G;
B = B.length() == 1 ? "0" + B : B;
stringBuffer.append("#");
stringBuffer.append(R);
stringBuffer.append(G);
stringBuffer.append(B);
return stringBuffer.toString();
}
08-16
4391