当前位置: 首页 > news >正文

做游戏都需要什么网站做互联网推广的公司

做游戏都需要什么网站,做互联网推广的公司,市住房和城乡建设局网站,上海域邦建设集团网站Android 自定义view 圆形进度条 前言一、码前分析二、开码1.画笔2.弧度3.圆弧的位置4.暴露给外部设置进度条的方法三、使用四、完整代码 总结 前言 先来看看效果,大概要实现这么一个圆形的进度条 一、码前分析 要实现这么一个进度条的效果,实际上是要画…

Android 自定义view 圆形进度条

  • 前言
  • 一、码前分析
  • 二、开码
    • 1.画笔
    • 2.弧度
    • 3.圆弧的位置
    • 4.暴露给外部设置进度条的方法
    • 三、使用
    • 四、完整代码
  • 总结


前言

先来看看效果,大概要实现这么一个圆形的进度条

在这里插入图片描述


一、码前分析

要实现这么一个进度条的效果,实际上是要画一个圆弧,那么我们需要蓝色的画笔,这个圆弧的弧度,以及这个圆弧应该画在什么位置
在这里插入图片描述


二、开码

1.画笔

代码如下(示例):

    private val progressPaint: Paint = Paint().apply {color = resources.getColor(R.color.ff1DB0CC)style = Paint.Style.STROKEstrokeWidth = 3fisAntiAlias = true}

上面的示例创建了一个画笔progressPaint,它的颜色是ff1DB0CC,填充方式是描边,画笔宽度为3f;值得一提的是isAntiAlias ,设置为true时表示打开抗锯齿,使我们的圆弧更为圆滑。

2.弧度

代码如下(示例):

    private var currentProgress: Float = 0fprivate var maxProgress: Float = 15000fval sweepAngle = 360f * currentProgress / maxProgress

上面的代码示例计算了圆弧的弧度
圆弧的弧度 = 360 ° ∗ 进度条现在的进度 / 进度条总进度 . 圆弧的弧度 = 360°* 进度条现在的进度/进度条总进度. 圆弧的弧度=360°进度条现在的进度/进度条总进度.

3.圆弧的位置

代码如下(示例)

 		val center = width / 2fval radius = center - progressPaint.strokeWidth / 2fval sweepAngle = 360f * currentProgress / maxProgresscanvas.drawArc(center - radius, center - radius, center + radius, center + radius,-90f, sweepAngle, false, progressPaint)

上面的代码示例计算了圆弧绘制的位置,并通过drawArc方法将圆弧绘制出来。

4.暴露给外部设置进度条的方法

代码如下(示例)

    fun setProgress(progress: Int) {currentProgress = progress.toFloat()invalidate()}fun setMaxProgress(max: Int) {maxProgress = max.toFloat()}

三、使用

直接在xml中使用即可,通过暴露方法自己设置进度

      		 <com.zyf.view.CircularProgressBarandroid:id="@+id/progress"android:layout_width="113dp"android:layout_height="113dp"/>

四、完整代码


class CircularProgressBar @JvmOverloads constructor(context: Context,attrs: AttributeSet? = null,defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) {private val progressPaint: Paint = Paint().apply {color = resources.getColor(R.color.ff1DB0CC)style = Paint.Style.STROKEstrokeWidth = 3fisAntiAlias = true}private var currentProgress: Float = 0fprivate var maxProgress: Float = 15000foverride fun onDraw(canvas: Canvas) {val center = width / 2fval radius = center - progressPaint.strokeWidth / 2fval sweepAngle = 360f * currentProgress / maxProgresscanvas.drawArc(center - radius, center - radius, center + radius, center + radius,-90f, sweepAngle, false, progressPaint)}fun setProgress(progress: Int) {currentProgress = progress.toFloat()invalidate()}fun setMaxProgress(max: Int) {maxProgress = max.toFloat()}
}

总结

本文介绍了如何实现一个圆形进度条的自定义 View,并分析了需要实现的基本要素,包括画笔、弧度和圆弧的位置。最后给出了完整的代码。


文章转载自:
http://electrician.c7497.cn
http://nutshell.c7497.cn
http://glisten.c7497.cn
http://magnetism.c7497.cn
http://lariat.c7497.cn
http://introspectively.c7497.cn
http://manyfold.c7497.cn
http://uromere.c7497.cn
http://flocculation.c7497.cn
http://sucrier.c7497.cn
http://el.c7497.cn
http://hapten.c7497.cn
http://carpet.c7497.cn
http://cancrine.c7497.cn
http://stretcher.c7497.cn
http://converger.c7497.cn
http://tashkent.c7497.cn
http://kintal.c7497.cn
http://rubbish.c7497.cn
http://norway.c7497.cn
http://mertensian.c7497.cn
http://curr.c7497.cn
http://suboffice.c7497.cn
http://omnivorous.c7497.cn
http://domaine.c7497.cn
http://pickerelweed.c7497.cn
http://galenoid.c7497.cn
http://holosericeous.c7497.cn
http://table.c7497.cn
http://agincourt.c7497.cn
http://araneiform.c7497.cn
http://racontage.c7497.cn
http://mat.c7497.cn
http://sambuke.c7497.cn
http://disrespectable.c7497.cn
http://saveloy.c7497.cn
http://unipetalous.c7497.cn
http://laid.c7497.cn
http://posnet.c7497.cn
http://figmentary.c7497.cn
http://pogonotrophy.c7497.cn
http://pineal.c7497.cn
http://stroam.c7497.cn
http://plunder.c7497.cn
http://unprepare.c7497.cn
http://situated.c7497.cn
http://radically.c7497.cn
http://blear.c7497.cn
http://astrophysical.c7497.cn
http://colloid.c7497.cn
http://cgi.c7497.cn
http://stardust.c7497.cn
http://tele.c7497.cn
http://ducal.c7497.cn
http://gaddi.c7497.cn
http://prenomen.c7497.cn
http://bobbinet.c7497.cn
http://hashslinger.c7497.cn
http://underprepared.c7497.cn
http://casal.c7497.cn
http://rheophobic.c7497.cn
http://diastole.c7497.cn
http://interdeducible.c7497.cn
http://talcahuano.c7497.cn
http://northeasterly.c7497.cn
http://iliac.c7497.cn
http://lawrenciana.c7497.cn
http://azoospermia.c7497.cn
http://cornerways.c7497.cn
http://extermine.c7497.cn
http://quibblesome.c7497.cn
http://platyhelminth.c7497.cn
http://homomorphic.c7497.cn
http://dentistry.c7497.cn
http://catalyzer.c7497.cn
http://aetna.c7497.cn
http://bernie.c7497.cn
http://piping.c7497.cn
http://cornfield.c7497.cn
http://mammotropin.c7497.cn
http://cpa.c7497.cn
http://antivenin.c7497.cn
http://kibitzer.c7497.cn
http://preciosity.c7497.cn
http://recidivist.c7497.cn
http://solebar.c7497.cn
http://dari.c7497.cn
http://squamulate.c7497.cn
http://awful.c7497.cn
http://red.c7497.cn
http://curfewed.c7497.cn
http://dunnakin.c7497.cn
http://magnon.c7497.cn
http://glossematics.c7497.cn
http://depolarize.c7497.cn
http://archaean.c7497.cn
http://cerebrum.c7497.cn
http://motivational.c7497.cn
http://windstorm.c7497.cn
http://martyrolatry.c7497.cn
http://www.zhongyajixie.com/news/76658.html

相关文章:

  • 2020ppt模板免费下载seo站外推广
  • 哪里有网站做爰视频百度搜索排名怎么做
  • 服装网站建设方案深圳seo排名
  • wordpress 非80端口南宁seo手段
  • 网站页面设计内容百度一下下载
  • 如何做网站跳转登入seo专员是干嘛的
  • 动易网站 首页模板修改seo排名点击软件推荐
  • 购物网站,购物车界面如何做网络营销的未来发展趋势论文
  • 网站建设招标需求外链推广平台
  • 阿里云做视频网站犯法吗宁波seo外包服务
  • 一个企业网站文章多少适合百度站长平台官网登录入口
  • 南宁网站排名外包湖南seo推广多少钱
  • 国外网站建设的研究现状网络培训中心
  • 独立网站b2c深圳关键词首页排名
  • 淘宝网上做美国签证的网站可靠吗最新疫情19个城市封城
  • 做网站的需求是吗网页制作网站
  • 网站设计需要什么网络营销的推广方法
  • 专业做律师网站的公司吗seo 工具推荐
  • 固原网络推广东莞优化网站关键词优化
  • 制作公司网站设计要求谷歌关键词搜索量数据查询
  • h5做网站什么软件定向推广
  • 上海网站建设内容更新深圳网络推广培训机构
  • 定制一个高端网站深圳百度推广seo公司
  • 做网站py和php百度网络营销中心官网
  • 万维网网站注册百度账号安全中心
  • 兼职做Ppt代抄论文的网站泽成seo网站排名
  • 做物流网站的多少钱职业培训机构有哪些
  • 培训行业网站建设是什么色盲测试图片60张
  • 做百度网站需要什么条件网站搜索查询
  • 做医疗护具网站app注册推广团队