常用颜色代码
#3F51B5 #303F9F #FF4081 #ff822b #C0C0C0 #A9A9A9 #808080 #696969 #ff3300 #ff0000 #e46634 #ff7e00 #de7424 #ed6d10 #FFB6C1 #DB7093 #FF1493 #DA70D6 #FF00FF #9400D3 #8B008B #4B0082 #483D8B #191970 #90EE90 #00FF00 #228B22 #006400 #7FFF00 #87CEFA #00BFFF #B0E0E6 #5F9EA0 #008B8B #FFFF00 #EEE8AA #FFD700 #DAA520 #B8860B #8B4513 #111111 #ffffff #a0a0a0 #00000000 #00479d #fff100 #d3ac71 #f39500 #601986 #704929 #26d4d0
常用获取颜色的方法
//#FFB6C1转成Intint color = Color.parseColor("#FFB6C1") //或者直接写成 0xFFFFB6C1//ARGB转Intint color = Color.argb(255, 255, 255, 255);//获取color.xml的颜色资源int color = getResources().getColor(R.color.red);
获取颜色RGB值
public static String toHexEncoding(int color) { String R, G, B; StringBuffer sb = new StringBuffer(); R = Integer.toHexString(Color.red(color)); G = Integer.toHexString(Color.green(color)); B = Integer.toHexString(Color.blue(color)); //判断获取到的R,G,B值的长度 如果长度等于1 给R,G,B值的前边添0 R = R.length() == 1 ? "0" + R : R; G = G.length() == 1 ? "0" + G : G; B = B.length() == 1 ? "0" + B : B; sb.append("0x"); sb.append(R); sb.append(G); sb.append(B); return sb.toString(); }
颜色代码在线转换