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>
相关推荐
前行的小黑炭14 分钟前
Android 协程的使用:结合一个环境噪音检查功能的例子来玩玩
android·java·kotlin
阿华的代码王国24 分钟前
【Android】内外部存储的读写
android·内外存储的读写
inmK14 小时前
蓝奏云官方版不好用?蓝云最后一版实测:轻量化 + 不限速(避更新坑) 蓝云、蓝奏云第三方安卓版、蓝云最后一版、蓝奏云无广告管理工具、安卓网盘轻量化 APP
android·工具·网盘工具
giaoho4 小时前
Android 热点开发的相关api总结
android
咖啡の猫6 小时前
Android开发-常用布局
android·gitee
程序员老刘6 小时前
Google突然“变脸“,2026年要给全球开发者上“紧箍咒“?
android·flutter·客户端
Tans56 小时前
Androidx Lifecycle 源码阅读笔记
android·android jetpack·源码阅读
雨白7 小时前
实现双向滑动的 ScalableImageView(下)
android
峥嵘life7 小时前
Android Studio新版本编译release版本apk实现
android·ide·android studio
studyForMokey9 小时前
【Android 消息机制】Handler
android