当前位置:网站首页>Compose canvas custom circular progress bar
Compose canvas custom circular progress bar
2022-07-26 07:16:00 【Ango can't move】
@Composable
fun CircleRing(boxWidthDp: Int, viewModel: TaskViewModel) {
Canvas(modifier = Modifier.size(boxWidthDp.dp), onDraw = {
val strokWidth = 30F
// Grey background
drawArc(
Color(0, 0, 0, 15),
startAngle = 160f,
sweepAngle = 220f,
useCenter = false,
style = Stroke(strokWidth, cap = StrokeCap.Round),
)
drawArc(
Color.White,
startAngle = 160f,
sweepAngle = viewModel.pointOfYearPercent,
useCenter = false,
style = Stroke(strokWidth, cap = StrokeCap.Round),
)
})
}
The progress is self-contained
// Academic year points
var pointOfYear by mutableStateOf(10000)
private set
// Progress of academic year points 220f * pointOfYear / Total academic year points
var pointOfYearPercent by mutableStateOf(0f)
private set
/**
* Update learning progress
*/
fun updatePointPercent() {
pointOfYearPercent = 220f * pointOfYear / totalPointOfYear
}
effect

The whole content data is as follows
Box(contentAlignment = Alignment.Center,
modifier = Modifier
.height(boxWidthDp.dp)
.padding(top = 16.dp)
) {
// ring
CircleRing(boxWidthDp = boxWidthDp, taskViewModel)
// Progress data
Column(modifier = Modifier
.align(Alignment.Center)
.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally) {
Text(buildAnnotatedString {
append(taskViewModel.pointOfYear.toString())
withStyle(SpanStyle(fontSize = 10.sp)) {
append(" branch ")
}
},
fontSize = 36.sp,
color = Color.White)
Text(text = " Academic year points ", fontSize = 12.sp,
color = Color.White)
}
}Remember to shift it upward in the next component 40dp Otherwise, there is too much space

边栏推荐
- 火焰图分析Flink反压
- Weekly tip 142: multi parameter constructors and explicit
- NiO implementation
- How to expand and repartition the C disk?
- 金融任务实例实时、离线跑批Apache DolphinScheduler在新网银行的三大场景与五大优化
- Leetcode 1184: distance between bus stops
- No .egg-info directory found in xxx\pip-pip-egg-info-mq
- Pycharm的相关配置:改字体样式和大小、更改图片背景、更改控制台输出的字体颜色
- [arm learning (8) AXF tool analysis]
- 敏捷整洁之道
猜你喜欢

问题:Can‘t download sh shellcheck. Please install it manually及shell脚本的一些命令使用

Drools (4): drools basic syntax (2)

Apache Dolphinscheduler3.0.0-beta-1 版本发布,新增FlinkSQL、Zeppelin任务类型

It's another summer of open source. 12000 project bonuses are waiting for you!

Opengauss simple version installation error
![[arm learning (8) AXF tool analysis]](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)
[arm learning (8) AXF tool analysis]

Yolov6 target detection practice: training your own data set (video tutorial)

MySQL安装教程-手把手教你安装

Analysis of strong tennis cup 2021 PWN competition -- baby_ diary

倒计时2日!基于 Apache DolphinScheduler&TiDB 的交叉开发实践,从编写到调度让你大幅提升效率
随机推荐
To do list application vikunja
Common programming shortcut keys of idea (take off after learning the operation)
火焰图分析Flink反压
Opencv learning basic functions
404 page best practices to improve user experience
Redis migrate tool migration error.
Usage of unity3d object pool
Unity3d-异步加载场景、进度条加载
Image annotation software reference
IDEA——使用@Slf4j打印日志
Opencv learning warp Perspective
Common CMD instructions
Yolov6 target detection practice: training your own data set (video tutorial)
常用的cmd指令
WPS or office compression of ppt
达人专栏 | 还不会用 Apache Dolphinscheduler?大佬用时一个月写出的最全入门教程【三】
树莓派连接天猫精灵音箱通过蓝牙播放音乐的方法
Curl post request on the server, using postman tool for parameter conversion
RGB-T追踪——【数据集基准】GTOT / RGBT210 / RGBT234 / VOT-2019-2020 / LasHeR / VTUAV
How to delete a statement audit log?