android progressbar 循环,如何在android中创建循环ProgressBar?

bfe4429a15ef5a3cbe196c06e48a645a.png

PIPIONE

自己创建这个很容易在您的布局中包含以下ProgressBar具有特定可绘制的内容(请注意,您应该从尺寸中获取宽度)。最大值在这里很重要:

    android:id="@+id/progressBar"

    style="?android:attr/progressBarStyleHorizontal"

    android:layout_width="150dp"

    android:layout_height="150dp"

    android:layout_alignParentBottom="true"

    android:layout_centerHorizontal="true"

    android:max="500"

    android:progress="0"

    android:progressDrawable="@drawable/circular" />现在使用以下形状在资源中创建drawable。使用半径(您可以使用innerRadius而不是innerRadiusRatio)和厚度值进行游戏。循环(Pre Lollipop OR API Level <21)   

        android:innerRadiusRatio="2.3"

        android:shape="ring"

        android:thickness="3.8sp" >

圆形(> = Lollipop OR API Level> = 21)    

        android:useLevel="true"

        android:innerRadiusRatio="2.3"

        android:shape="ring"

        android:thickness="3.8sp" >

默认情况下,API Level 21(Lollipop)中的useLevel为“false”。开始动画在代码中接下来使用an ObjectAnimator来ProgessBar为布局的progress字段设置动画。ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.progressBar);ObjectAnimator animation = ObjectAnimator.ofInt(progressBar, "progress", 0, 500); // see this max value coming back here, we animate towards that valueanimation.setDuration(5000); // in millisecondsanimation.setInterpolator(new DecelerateInterpolator());animation.start();停止动画progressBar.clearAnimation();PS不同于上面的例子,它给出了流畅的动画。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值