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>
相关推荐
帅次3 分钟前
Android 高级工程师面试速记版
android·java·面试·kotlin·binder·zygote·android runtime
AI玫瑰助手8 分钟前
Python基础:字典的键值对结构与增删改查操作
android·开发语言·python
我命由我1234510 分钟前
Android 开发问题:Raw use of parameterized class ‘Class‘
android·java·java-ee·android studio·android jetpack·android-studio·android runtime
黄林晴16 分钟前
根治协程陋习!官方级协程Skill发布
android·kotlin
浪客川1 小时前
UniFFI 跨平台开发Rust 与 Android (Kotlin) 集成
android·rust·kotlin
AirDroid_cn1 小时前
荣耀MagicOS 10系统设备查找:关机后如何通过附近荣耀设备定位?
android·智能手机·荣耀手机
iwS2o90XT1 小时前
Kotlin标准库:实用函数
android·开发语言·kotlin
0pen11 小时前
ZygiskNext 源码解析(一):总体架构与启动链路
android·开源·zygote
weixin_394758033 小时前
直播间小程序码生成问题修复代码清单
android·小程序·apache
苦瓜花10 小时前
【Android】活动
android