将透明度的百分比转化为十六进制的字符串

2018-11-27  本文已影响0人  迷途之中小书童
public static String percent2HexStr(double percent) {
    try {
        double j = Math.round(percent * 100) / 100.0d;
        int alpha = (int) Math.round(j * 255);
        String hex = Integer.toHexString(alpha).toUpperCase();
        if (hex.length() == 1) {
            hex = "0" + hex;
        }

// Log.d("hex", "percent:" + percent + "|" + "hex:" + hex);
return hex;
} catch (Exception e) {
// do nothing
}
}

上一篇 下一篇

猜你喜欢

热点阅读