位置: 编程技术 - 正文
推荐整理分享打造一个可分割的华丽圆形进度条,适合倒计时等场景(可分割项目),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:可分割部分,可分割可注册什么意思,可分割部分,可分割性,可分割项目,可分割项目,可分割项目,打造一个可分割的空间,内容如对您有帮助,希望把文章链接给更多的朋友!
又到了周末时光,前段时间一直在忙自己开发的app,最近新版上架了,终于有时间干些其他事情了,这个进度条是从项目中提取出来的,主要知识点就是自定义控件,自定义控件的三部曲:测量、布局、绘制,在这里主要是使用绘制。一直想写好一个自己的博客,作为一个知识分享的空间,也同时是自己知识的记事本,但总是被各种时间占用,不知道你们是不是和我一样。
这里主要是对api的认识,重点是使用以下函数进行画弧,下面是IDE直接提示的函数说明:void android.graphics.Canvas.drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter, Paint paint)Draw the specified arc, which will be scaled to fit inside the specified oval.
If the start angle is negative or >= , the start angle is treated as start angle modulo .
If the sweep angle is >= , then the oval is drawn completely. Note that this differs slightly from SkPath::arcTo, which treats the sweep angle modulo . If the sweep angle is negative, the sweep angle is treated as sweep angle modulo
The arc is drawn clockwise. An angle of 0 degrees correspond to the geometric angle of 0 degrees (3 o'clock on a watch.)
Parameters:oval The bounds of oval used to define the shape and size of the arcstartAngle Starting angle (in degrees) where the arc beginssweepAngle Sweep angle (in degrees) measured clockwiseuseCenter If true, include the center of the oval in the arc, and close it if it is being stroked. This will draw a wedgepaint The paint used to draw the arc我们主要看一下这个函数的几个参数的意义,第一个参数oval需要传入一个RectF,也就是包裹圆形(椭圆)的最大矩形;startAngle起始角度,从0开始计算;sweepAngle顺时针扫描角度,这个参数是个关键,指的是从起始角度开始需要画的角度,而不是从0开始的结束角度;useCenter,true画实心的圆、false只画边框;paint需要的Paint对象,可设置一系列属性,如抗锯齿、画笔颜色等等
二、自定义可分割圆形进度条先来看下效果图:
attrs.xml文件,这里面定义了RoundProgressBar可在layout中使用的特定属性RoundProgressBar.java,主要的实现类,通过继承View并重写onDraw方法实现圆形可分割进度条
三、使用自定义可分割圆形进度条和使用其他自定义控件没两样,首先需要xmlns:android_custom="androi实现自定义标题栏、自定义光标 概要申请专栏成功啦~好开心,嘻嘻,还会坚持下去的,希望一切都会有好结果!!这是专栏的第一讲,我们知道如果用android自带的标题栏好low的,在怎
JAVA 面向对象和集合知识点总结(6.更新) 转载请注明出处:
Android Studio常用快捷键 alt+insert生成构造方法和setgetalt+1打开和关闭导航目录alt+shift+up/down上下移动行ctrl+d复制一行ctrl+y删除行ctrl+q打开帮助文档ctrl+o/ioveride/implementctrl+shift+space
标签: 可分割项目
本文链接地址:https://www.jiuchutong.com/biancheng/386811.html 转载请保留说明!友情链接: 武汉网站建设