美文网首页
android 动态给color加透明度

android 动态给color加透明度

作者: 小相柳 | 来源:发表于2019-10-09 09:12 被阅读0次
/**
  * 给color添加透明度
  * @param alpha 透明度 0f~1f
  * @param baseColor 基本颜色
  * @return
  */
public static int getColorWithAlpha(float alpha, int baseColor) {
   int a = Math.min(255, Math.max(0, (int) (alpha * 255))) << 24;
   int rgb = 0x00ffffff & baseColor;
   return a + rgb;
}

相关文章

网友评论

      本文标题:android 动态给color加透明度

      本文链接:https://www.haomeiwen.com/subject/pfswpctx.html