ShimmerLayout.java 文件源码

java
阅读 31 收藏 0 点赞 0 评论 0

项目:ShimmerLayout 作者:
private Bitmap getSourceMaskBitmap() {
    if (sourceMaskBitmap != null) {
        return sourceMaskBitmap;
    }

    int width = maskRect.width();
    int height = getHeight();

    final int edgeColor = reduceColorAlphaValueToZero(shimmerColor);
    LinearGradient gradient = new LinearGradient(
            -maskRect.left, 0,
            width + maskRect.left, 0,
            new int[]{edgeColor, shimmerColor, shimmerColor, edgeColor},
            getGradientColorDistribution(),
            Shader.TileMode.CLAMP);
    Paint paint = new Paint();
    paint.setShader(gradient);

    sourceMaskBitmap = createBitmap(width, height);
    Canvas canvas = new Canvas(sourceMaskBitmap);
    canvas.rotate(shimmerAngle, width / 2, height / 2);
    canvas.drawRect(-maskRect.left, maskRect.top, width + maskRect.left, maskRect.bottom, paint);

    return sourceMaskBitmap;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号