android 半透明色值_Android颜色值(#AARRGGBB)透明度/不透明度百分比和十六进制对应关系以及计算方法...

透明度表格960e15f7bc9d3b52e4f01d9d2f0f01a4.png

透明度百分比和十六进制对应关系计算方法:@Test

public void rgba() throws Exception {

System.out.println("透明度 | 十六进制");

System.out.println("---- | ----");

for (double i = 1; i >= 0; i -= 0.01) {

i = Math.round(i * 100) / 100.0d;

int alpha = (int) Math.round(i * 255);

String hex = Integer.toHexString(alpha).toUpperCase();

if (hex.length() == 1) {

hex = "0" + hex;

}

int percent = (int) (i * 100);

System.out.println(String.format("%d%% | %s", percent, hex));

}

}

不透明度表格3a93ba40bc7a1cf9ebb6c9f1b256ee15.png

不透明度百分比和十六进制对应关系计算方法:public void rgba() throws Exception {

System.out.println("不透明度 | 十六进制");

System.out.println("---- | ----");

for (int percent = 0; percent <= 100; percent++) {

int alpha = Math.round(255 * percent * 1.0f / 100f);

String hex = Integer.toHexString(alpha).toUpperCase();

if (hex.length() == 1) {

hex = "0" + hex;

}

System.out.println(String.format("%d%% | %s", percent, hex));

}

}

用于查询。本文整理来自:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值