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>
相关推荐
冬奇Lab13 分钟前
AudioRecord音频录制流程深度解析
android·音视频开发·源码阅读
alexhilton3 小时前
Jetpack Compose中的富文本输入
android·kotlin·android jetpack
兄弟加油,别颓废了。3 小时前
ctf.show_web4
android
哔哔龙5 小时前
Android OpenCV 实战:图片轮廓提取与重叠轮廓合并处理
android·算法
tangweiguo030519876 小时前
Android SSE 流式接收:从手写到框架的进阶之路
android
大尚来也7 小时前
PHP 反序列化漏洞深度解析:从原理利用到 allowed_classes 防御实战
android·开发语言·php
sp42a7 小时前
通过 RootEncoder 进行安卓直播 RTSP 推流
android·推流·rtsp
SY.ZHOU8 小时前
移动端架构体系(一):组件化
android·ios·架构·系统架构
恋猫de小郭9 小时前
Android 17 新适配要求,各大权限进一步收紧,适配难度提升
android·前端·flutter
流星白龙9 小时前
【MySQL】9.MySQL内置函数
android·数据库·mysql