当前位置:网站首页>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

边栏推荐
- Leetcode 1184: distance between bus stops
- anaconda安装教程-手把手教你安装
- Curl post request on the server, using postman tool for parameter conversion
- C51 and MDK coexist keil5 installation tutorial
- Countdown 2 days! Based on the cross development practice of Apache dolphin scheduler & tidb, you can greatly improve your efficiency from writing to scheduling
- MySQL安装教程-手把手教你安装
- 成为 Apache 贡献者,So easy!
- 文件服务器FastDFS
- 如何删除语句审计日志?
- 从XSS Playload 学习浏览器解码
猜你喜欢

Apache dolphin scheduler & tidb joint meetup | focus on application development capabilities under the development of open source ecosystem
![[arm learning (8) AXF tool analysis]](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)
[arm learning (8) AXF tool analysis]

Opencv learning warp Perspective

Opencv learn resize and crop

成为 Apache 贡献者,So easy!

Lite actor: lightweight optimization of ark actor concurrency model

Opencv learning color detection

Opencv learning drawing shapes and text

Apache DolphinScheduler&TiDB联合Meetup | 聚焦开源生态发展下的应用开发能力

【C语言】你真的了解printf吗?(printf典型易错,强烈建议收藏)
随机推荐
A guide for you to fully use TS
Apache Dolphinscheduler3.0.0-beta-1 版本发布,新增FlinkSQL、Zeppelin任务类型
Yolov5 improvements: add attention mechanism (video tutorial)
Opencv learn resize and crop
Advanced Mathematics (Seventh Edition) Tongji University exercises 2-5 personal solutions
常用的cmd指令
Do you want to restart the database to replace the license?
Curl post request on the server, using postman tool for parameter conversion
Lite actor: lightweight optimization of ark actor concurrency model
PR字幕制作
HCIP --- MPLS技术
Drools (4): drools basic syntax (2)
配置Flask
I don't understand the MySQL 57 version under centos7 when I encounter a problem. I was informed by big Shen who knows it
Question: can't download sh shellcheck Please install it manually and some commands of shell script
Tips when entering a formula in latex
Basic operations and common functions of MySQL table creation
QT: list box, table, tree control
每周小贴士#142:多参数构造函数和explicit
优炫数据库JDBC打开日志方式有哪些