android 半透明色值

编程入门 行业动态 更新时间:2024-10-26 11:18:17

<a href=https://www.elefans.com/category/jswz/34/1771384.html style=android 半透明色值"/>

android 半透明色值

透明度表格

透明度百分比和十六进制对应关系计算方法:@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));

}

}

不透明度表格

不透明度百分比和十六进制对应关系计算方法: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));

}

}

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

更多推荐

android 半透明色值

本文发布于:2024-03-05 06:47:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1711591.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!