首页 > 其他 > 详细

获取Color的几种方式

时间:2019-02-02 13:55:44      阅读:204      评论:0      收藏:0      [点我收藏+]

 

#11223344 格式,11位表示透明度,为0时完全透明,为255时完全不透明,后三个分量依次表示R,G,B颜色参数。

//获取颜色字符串  得到 #ffffff格式字符串 
// colorTest 为 #FF0000

String c0=this.getResources().getString((int)R.color.colorTest);

//获取颜色数值,为8位数表示

int c1 = this.getResources().getColor(R.color.colorTest);

int c2 = Color.parseColor("#FF0000");

int c3 = 0xFF0000;

int c4 = 0xFFFF0000;

int c5= Color.argb(255,255,0,0);

Log.d("fff","Color 0 === "+c0);
Log.d("fff","Color 1 === "+c1);
Log.d("fff","Color 2 === "+c2);
Log.d("fff","Color 3 === "+c3);
Log.d("fff","Color 4 === "+c4);
Log.d("fff","Color 5 === "+c5);

 

打印LOG:

02-02 13:08:58.672 15085-15085/com.code.tx1n.tochat D/fff: Color 0 === #ffff0000
02-02 13:08:58.672 15085-15085/com.code.tx1n.tochat D/fff: Color 1 === -65536
02-02 13:08:58.672 15085-15085/com.code.tx1n.tochat D/fff: Color 2 === -65536
02-02 13:08:58.672 15085-15085/com.code.tx1n.tochat D/fff: Color 3 === 16711680
02-02 13:08:58.672 15085-15085/com.code.tx1n.tochat D/fff: Color 4 === -65536
02-02 13:08:58.672 15085-15085/com.code.tx1n.tochat D/fff: Color 5 === -65536

 

获取Color的几种方式

原文:https://www.cnblogs.com/xfdmyghdx/p/10348247.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!