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

海南百度推广公司长春seo推广

海南百度推广公司,长春seo推广,做一个网站需要到哪里做,可以自己做图片的软件一个最基础的自定义View 圆形进度条,可设置背景色、进度条颜色(渐变色)下载进度控制;可二次定制度高; 核心代码: Overrideprotected void onDraw(NonNull Canvas canvas) {super.onDraw(canvas);int mW g…

一个最基础的自定义View 圆形进度条,可设置背景色、进度条颜色(渐变色)下载进度控制;可二次定制度高;

核心代码:

    @Overrideprotected void onDraw(@NonNull Canvas canvas) {super.onDraw(canvas);int mW = getMeasuredWidth();int mH = getMeasuredHeight();int centerX = mW/2;int centerY = mH/2;Log.i(TAG, "onDraw: "+mW +"-" +mH);//画背景色canvas.save();paintBg.setColor(backgroundColor);RectF rectBg = new RectF(strokeWidth,strokeWidth,mW-strokeWidth,mH-strokeWidth);canvas.drawArc(rectBg,0,360,false , paintBg);//画进度条颜色float ratio  = (float) Math.min(progress / max , 1.00);paint.setColor(loadingColor); //设置进度条颜色
//        SweepGradient sweepGradient = new SweepGradient(centerX , centerY , new int[]{loadingColor , Color.YELLOW} , null);
//        paint.setShader(sweepGradient); //设置进度条渐变色paint.setStrokeCap(Paint.Cap.ROUND); 设置画笔边缘为半圆状canvas.drawArc(rectBg,0,360*ratio,false , paint);canvas.restore();//画中间的文案paintText.setTextSize(dp2px(18));paintText.setColor(Color.BLACK);paintText.setTextAlign(Paint.Align.CENTER);Paint.FontMetrics fontMetrics = paintText.getFontMetrics();float disY = (fontMetrics.bottom - fontMetrics.top) / 2 - fontMetrics.bottom;canvas.drawText(progress+"%" , centerX , centerY+disY , paintText);}

全部代码:

package com.cuichen.mytestdemo.view;import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.SweepGradient;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;import androidx.annotation.NonNull;
import androidx.annotation.Nullable;import com.cuichen.mytestdemo.R;public class CircleProgressView extends View {private final String TAG = CircleProgressView.class.getSimpleName();public CircleProgressView(Context context) {super(context);}public CircleProgressView(Context context, @Nullable AttributeSet attrs) {super(context, attrs);initAttrs(attrs);}public CircleProgressView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);initAttrs(attrs);}public CircleProgressView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {super(context, attrs, defStyleAttr, defStyleRes);initAttrs(attrs);}private void initAttrs( @Nullable AttributeSet attrs){TypedArray typedArray = getContext().obtainStyledAttributes(attrs , R.styleable.CircleProgress);try{backgroundColor = typedArray.getColor(R.styleable.CircleProgress_backgroundColorCircle , Color.parseColor("#5503DAC5"));loadingColor = typedArray.getColor(R.styleable.CircleProgress_progressColorCircle ,Color.parseColor("#FF018786"));strokeWidth = (int) typedArray.getDimension(R.styleable.CircleProgress_strokeWidthCircle , 18);max = typedArray.getInt(R.styleable.CircleProgress_maxCircle , 100);progress = typedArray.getInt(R.styleable.CircleProgress_progressCircle , 50);}catch (Exception e){typedArray.recycle();}}private int strokeWidth = 18;private float progress = 0f;private float max = 100f;private int backgroundColor;private int loadingColor;final int DEFAULT_HEIGHT_DP = 66;Paint paintBg , paint , paintText;void init(){paintBg = new Paint();paintBg.setAntiAlias(true);paintBg.setStyle(Paint.Style.STROKE);paintBg.setStrokeWidth(strokeWidth);paint = new Paint();paint.setAntiAlias(true);paint.setStyle(Paint.Style.STROKE);paint.setStrokeWidth(strokeWidth);paintText = new Paint();paintText.setAntiAlias(true);}public void setProgress(int progress){this.progress = progress;invalidate();}@Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {super.onMeasure(widthMeasureSpec, heightMeasureSpec);Log.i(TAG, "onMeasure: ");int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec);int height = 0;switch (heightSpecMode){case MeasureSpec.AT_MOST:height = dp2px(DEFAULT_HEIGHT_DP);break;case MeasureSpec.EXACTLY:case MeasureSpec.UNSPECIFIED:height = heightSpecSize;break;}setMeasuredDimension(widthSpecSize, height);if(paint == null) {init();}}//RectF//left:左边坐标;在绘制中常表示为起点的Y轴坐标//top:上边左边;在绘制中常表示为起点的X轴坐标//right:右边坐标;在绘制中常表示为终点的X轴坐标//bottom:下边坐标;在绘制中常表示为终点的Y轴坐标@Overrideprotected void onDraw(@NonNull Canvas canvas) {super.onDraw(canvas);int mW = getMeasuredWidth();int mH = getMeasuredHeight();int centerX = mW/2;int centerY = mH/2;Log.i(TAG, "onDraw: "+mW +"-" +mH);//画背景色canvas.save();paintBg.setColor(backgroundColor);RectF rectBg = new RectF(strokeWidth,strokeWidth,mW-strokeWidth,mH-strokeWidth);canvas.drawArc(rectBg,0,360,false , paintBg);//画进度条颜色float ratio  = (float) Math.min(progress / max , 1.00);paint.setColor(loadingColor); //设置进度条颜色
//        SweepGradient sweepGradient = new SweepGradient(centerX , centerY , new int[]{loadingColor , Color.YELLOW} , null);
//        paint.setShader(sweepGradient); //设置进度条渐变色paint.setStrokeCap(Paint.Cap.ROUND); 设置画笔边缘为半圆状canvas.drawArc(rectBg,0,360*ratio,false , paint);canvas.restore();//画中间的文案paintText.setTextSize(dp2px(18));paintText.setColor(Color.BLACK);paintText.setTextAlign(Paint.Align.CENTER);Paint.FontMetrics fontMetrics = paintText.getFontMetrics();float disY = (fontMetrics.bottom - fontMetrics.top) / 2 - fontMetrics.bottom;canvas.drawText(progress+"%" , centerX , centerY+disY , paintText);}private int dp2px(int dp){float density = getContext().getResources().getDisplayMetrics().density;return (int) (dp * density);}
}
    <declare-styleable name="CircleProgress"><attr name="backgroundColorCircle" format="color"/><attr name="progressColorCircle" format="color"/><attr name="strokeWidthCircle" format="dimension"/><attr name="maxCircle" format="integer"/><attr name="progressCircle" format="integer"/></declare-styleable>

http://www.hengruixuexiao.com/news/47722.html

相关文章:

  • 哪个网站可以做问卷凡科建站登录官网
  • 企业网站的建立主要用于企业内部发布信息秦皇岛seo优化
  • 日照网红民宿班级优化大师下载安装
  • 哪些企业会考虑做网站厦门seo怎么做
  • php网站开发技术课程一个公司可以做几个百度推广
  • 做的最好的美女视频网站百度竞价在哪里开户
  • 百度做的网站字体侵权吗上海疫情最新数据
  • 网站开发视频教程下载18款禁用看奶app入口
  • 专业的高密做网站的杭州优化外包
  • ps做汽车网站下载地址互联网营销师课程
  • 网站顾客评价百度浏览器在线打开
  • 北京知名网站设计公司ios微信上的pdf乱码
  • 任丘网站制作搜索引擎优化的基本内容
  • asp.net制作网站开发国内seo公司排名
  • html5新闻网站站长工具樱花
  • 医院网站建设方案详细综合权重查询
  • logo在线设计免费生成器网站关键词优化推广哪家好
  • 网站改版的方式大致有品牌整合推广
  • 公司宣传网站怎么做nba最新消息新闻
  • 建设股份公司网站网站分析培训班
  • 怎样做企业手机网站建设百度app推广方法
  • 四库一平台建筑企业资质查询sem和seo是什么
  • 电商网站商品排序分类怎么做软文营销的优势
  • 我想学网站建设凡科小程序
  • 处方药可以做网站吗公司seo是指什么意思
  • 做lol直播网站长沙网站优化价格
  • 现在清算组备案在哪个网站做搜索软件排行榜前十名
  • 无锡网站设计公司电话微信做单30元一单
  • 东莞疫情最新消息今天seo站长综合查询工具
  • 品牌型网站制作价格网络推广方法技巧