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>
相关推荐
毕设源码-朱学姐20 分钟前
【开题答辩全过程】以 基于Android的留守儿童贫困资助管理系统的设计与实现为例,包含答辩的问题和答案
android
愤怒的代码26 分钟前
深入理解 IdleHandler:从启动优化到内存管理
android·架构·kotlin
恋猫de小郭29 分钟前
OpenAI :你不需要跨平台框架,只需要在 Android 和 iOS 上使用 Codex
android·前端·openai
路在脚下,梦在心里1 小时前
net学习总结
android·学习
走在路上的菜鸟1 小时前
Android学Dart学习笔记第二十节 类-枚举
android·笔记·学习·flutter
星光一影1 小时前
合成植物大战僵尸 安卓原生APP Cocos游戏 支持Sigmob
android·游戏·php·html5·web app
2501_915918411 小时前
iOS 项目中证书管理常见的协作问题
android·ios·小程序·https·uni-app·iphone·webview
allk551 小时前
Android ANR 深度起底:从系统埋雷机制到全链路治理体系
android
满天星83035771 小时前
【Linux】信号(下)
android·linux·运维·服务器·开发语言·性能优化
2501_915918411 小时前
提升 iOS 应用安全审核通过率的一种思路,把容易被拒的点先处理
android·安全·ios·小程序·uni-app·iphone·webview