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>
相关推荐
奔跑吧 android2 小时前
【车载audio】【AudioPolicyManager 01】【AudioPolicyClient 类介绍】
android·audio·audioflinger·aosp15·音频开发·车载音频·audiopolicym
敲上瘾3 小时前
磁盘到 inode:深入理解 Linux ext 文件系统底层原理
android·linux·运维·文件系统
hewence13 小时前
Kotlin CoroutineScope解密
android·开发语言·kotlin
遇雪长安3 小时前
高通安卓设备DIAG端口启用指南
android·adb·usb·dm·qpst·diag·qxdm
华章酱4 小时前
MySQL EXPLAIN 完全解读:从执行计划到索引优化
android·数据库·mysql
2501_915921434 小时前
Fastlane 结合 AppUploader 来实现 CI 集成自动化上架
android·运维·ci/cd·小程序·uni-app·自动化·iphone
贤泽4 小时前
Android 15 AOSP Notification分析
android
特立独行的猫a4 小时前
腾讯Kuikly多端框架(KMP)实战:轮播图的完整实现
android·harmonyos·轮播图·jetpack compose·kuikly
2501_915921434 小时前
iOS 抓包怎么绕过 SSL Pinning 证书限制,抓取app上的包
android·网络协议·ios·小程序·uni-app·iphone·ssl
陈健平4 小时前
用 Kimi 2.5 Agent 从 0 搭建「宇宙吞噬,ps:和球球大作战这种差不多」对抗小游戏(Canvas 粒子特效 + AI Bot + 排行榜)
android·人工智能·agent·kimi2.5