android 固定进度环形刷新效果

android 固定进度无限旋转的环形效果

效果图

Activity 中使用

kotlin 复制代码
val rotation: ObjectAnimator = ObjectAnimator.ofFloat(progressBar, "rotation", 0f, 360f)
rotation.duration = ·000 // 旋转持续时间为2秒
rotation.repeatCount = ObjectAnimator.INFINITE // 设置为无限循环
rotation.interpolator = LinearInterpolator() // 设置匀速插值器
rotation.start()

布局样式

kotlin 复制代码
<ProgressBar
    android:id="@+id/progressBar"
    android:background="@drawable/pb_circular_bg"
    android:progressDrawable="@drawable/pd_circular_progress"
    android:indeterminateOnly="false"
    android:indeterminate="false"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:max="100"
    android:progress="25"/>

背景样式 pb_circula_bg.xml

kotlin 复制代码
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:innerRadiusRatio="3"
    android:shape="ring"
    android:thicknessRatio="8"
    android:useLevel="false">
    <solid android:color="@color/theme_c_d9" />
</shape>

进度样式 pd_circular_progress.xml

kotlin 复制代码
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:innerRadiusRatio="3"
    android:shape="ring"
    android:thicknessRatio="8"
    android:useLevel="true">
    <solid android:color="@color/colorPrimary" />
</shape>
相关推荐
网络研究院2 小时前
Android 安卓内存安全漏洞数量大幅下降的原因
android·安全·编程·安卓·内存·漏洞·技术
凉亭下2 小时前
android navigation 用法详细使用
android
小比卡丘5 小时前
C语言进阶版第17课—自定义类型:联合和枚举
android·java·c语言
前行的小黑炭5 小时前
一篇搞定Android 实现扫码支付:如何对接海外的第三方支付;项目中的真实经验分享;如何高效对接,高效开发
android
落落落sss7 小时前
MybatisPlus
android·java·开发语言·spring·tomcat·rabbitmq·mybatis
代码敲上天.7 小时前
数据库语句优化
android·数据库·adb
GEEKVIP10 小时前
手机使用技巧:8 个 Android 锁屏移除工具 [解锁 Android]
android·macos·ios·智能手机·电脑·手机·iphone
model200512 小时前
android + tflite 分类APP开发-2
android·分类·tflite
彭于晏68912 小时前
Android广播
android·java·开发语言
与衫13 小时前
掌握嵌套子查询:复杂 SQL 中 * 列的准确表列关系
android·javascript·sql