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


表格:

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

@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));
    }
}

用于查询。本文整理来自:https://blog.csdn.net/ouyang_peng/article/details/51896521

声明:TIL|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA[ZH]协议进行授权

转载:转载请注明原文链接 - Android颜色值(#AARRGGBB)透明度百分比和十六进制对应关系以及计算方法


Life is very interesting. In the end, some of your greatest pains become your greatest strengths.