LemonBubblePrivateAnimationTool.java 文件源码

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

项目:LemonBubble4Android 作者:
void setCornerRadius(View view, int radius, int color) {
    radius = _DP(radius);
    int borderWidth = 0;// 加边框后会出现空心圆角矩形的效果,所以设置为0
    float[] outerRadius = new float[8];
    float[] innerRadius = new float[8];
    for (int i = 0; i < 8; i++) {
        outerRadius[i] = radius + borderWidth;
        innerRadius[i] = radius;
    }
    ShapeDrawable shapeDrawable = // 创建图形drawable
            new ShapeDrawable(
                    // 创建圆角矩形
                    new RoundRectShape(outerRadius,
                            new RectF(borderWidth, borderWidth, borderWidth, borderWidth),
                            innerRadius));
    shapeDrawable.getPaint().setColor(color);// 使用指定的颜色绘制,即背景颜色
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        // 高版本SDK使用新的API
        view.setBackground(shapeDrawable);
    } else {
        view.setBackgroundDrawable(shapeDrawable);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号