您当前的位置: 首页 >  动画

蓝不蓝编程

暂无认证

  • 0浏览

    0关注

    706博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

安卓动画样例-圆环变多变少

蓝不蓝编程 发布时间:2020-07-09 17:13:42 ,浏览量:0

效果图

代码
class CircleViewAnim(context: Context, attributeSet: AttributeSet? = null) :
    View(context, attributeSet) {
    private var mPaint: Paint = Paint()
    private var mTimer: Timer? = null
    private var basePadding = 20
    private var count = 0
    private var maxCount = 20
    private var isIncreasing = true

    init {
        mPaint.color = Color.parseColor("#fab27b")
        mPaint.isAntiAlias = true
        mPaint.style = Paint.Style.STROKE
        mPaint.strokeWidth = 10f
        startAnim()
    }

    private fun drawCircle(canvas: Canvas) {
        (0..count).forEach {
            var padding = it * basePadding
            canvas.drawCircle((width / 2).toFloat(), (height / 2).toFloat(), 10f + padding, mPaint)
        }
        if (isIncreasing) {
            count++
        } else {
            count--
        }
        if (count >= maxCount) {
            isIncreasing = false
        } else if (count             
关注
打赏
1639405877
查看更多评论
0.1428s