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

包包网站建设什么是搜索引擎营销?

包包网站建设,什么是搜索引擎营销?,wordpress实现复制图片自动保存,建设网站的网站自定义View画一个类似下图的圆环: 分为三步:画底部圆,上层圆,还有文字 其中上层圆需要渐变颜色,并且和数字代表的程度统一。 代码如下: public class ScoreCircle extends View {private static final S…

自定义View画一个类似下图的圆环:

分为三步:画底部圆,上层圆,还有文字

其中上层圆需要渐变颜色,并且和数字代表的程度统一。

代码如下:

public class ScoreCircle extends View {private static final String TAG = "ScoreCircleLog";private int circleRadius;//圆半径private int circleStroke;//线宽private int totalSize;//View总大小private int padding;private int firstCircleColor;private int secondStartColor;private int secondEndColor;private SweepGradient mGradient;private Matrix gradientMatrix;private int frontColor;private int frontSize;private int totalAngle = 349;//最多只能转350度,不然会重合private float totalScore = 100f; //总分100private float currentScore = 60f;//private DecimalFormat decimalFormat=new DecimalFormat(".0");private Paint mPaint;public ScoreCircle(Context context) {super(context);}public ScoreCircle(Context context, @Nullable AttributeSet attrs) {this(context, attrs,0);}public ScoreCircle(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);initAttrs(attrs,context);initPaint();}private void initAttrs(AttributeSet attrs,Context context) {TypedArray typedArray = this.getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.ScoreCircle, 0, 0);try {int width = typedArray.getLayoutDimension(R.styleable.ScoreCircle_android_layout_width, (int) this.getResources().getDimension(R.dimen.scoreCircle_size));int height = typedArray.getLayoutDimension(R.styleable.ScoreCircle_android_layout_height, (int)this.getResources().getDimension(R.dimen.scoreCircle_size));setTotalSize(width,height);padding = (int) typedArray.getDimension(R.styleable.ScoreCircle_padding, this.getResources().getDimension(R.dimen.scoreCircle_padding));circleStroke = (int) typedArray.getDimension(R.styleable.ScoreCircle_stroke, this.getResources().getDimension(R.dimen.scoreCircle_stroke));firstCircleColor = typedArray.getColor(R.styleable.ScoreCircle_firstCircleColor,ContextCompat.getColor(context,R.color.ScoreCircle_first_color));secondStartColor = typedArray.getColor(R.styleable.ScoreCircle_sendColorStart,ContextCompat.getColor(context,R.color.ScoreCircle_second_start));secondEndColor = typedArray.getColor(R.styleable.ScoreCircle_sendColorEnd,ContextCompat.getColor(context,R.color.ScoreCircle_second_end));frontColor = typedArray.getColor(R.styleable.ScoreCircle_front_color,ContextCompat.getColor(context,R.color.ScoreCircle_front_color));frontSize = (int) typedArray.getDimension(R.styleable.ScoreCircle_front_size,AppUtils.dpToPx(context,22));} finally {typedArray.recycle();}}public void setScore(float score) {if (score > 100)score = 100;if (score < 0)score = 0;this.currentScore = score;invalidate();}private void setTotalSize(int width,int height){if (width == WRAP_CONTENT || width == MATCH_PARENT){if (width == WRAP_CONTENT){totalSize = (int)this.getResources().getDimension(R.dimen.scoreCircle_size);}}else {if (width > height){totalSize = width;}elsetotalSize = height;}}private void initPaint(){mPaint = new Paint();mGradient = new SweepGradient(0,0,secondStartColor,secondEndColor);gradientMatrix = new Matrix();}@Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {totalSize = resolveSize(totalSize,widthMeasureSpec);circleRadius = totalSize/2 - padding - circleStroke/2;setMeasuredDimension(totalSize,totalSize);}//  invalidate();  ondraw//  requestLayout(); onMeasure onlayout@Overrideprotected void onDraw(Canvas canvas) {drawFirstCircle(canvas);drawSecondCircle(canvas);drawText(canvas);}//底部圆private void drawFirstCircle(Canvas canvas) {mPaint.reset();mPaint.setAntiAlias(true);mPaint.setStrokeWidth(circleStroke);mPaint.setColor(firstCircleColor);mPaint.setStyle(Paint.Style.STROKE);canvas.drawCircle(totalSize/2,totalSize/2,circleRadius,mPaint);}//表层圆@SuppressLint("NewApi")private void drawSecondCircle(Canvas canvas) {mPaint.reset();mPaint.setAntiAlias(true);mPaint.setStrokeWidth(circleStroke+2);mPaint.setStyle(Paint.Style.STROKE);mPaint.setStrokeCap(Paint.Cap.ROUND);mPaint.setShader(mGradient);float angle = (currentScore / totalScore)*totalAngle;canvas.save();gradientMatrix.setTranslate(totalSize/2,totalSize/2);mGradient.setLocalMatrix(gradientMatrix);// gradientMatrix.setRotate(0.9f,totalSize/2,totalSize/2);canvas.rotate(-90,totalSize/2,totalSize/2);//  mGradient.setLocalMatrix(gradientMatrix);canvas.drawArc(padding+circleStroke/2, padding+circleStroke/2 ,totalSize - padding-circleStroke/2, totalSize - padding-circleStroke/2,6,angle,false,mPaint);canvas.restore();}//中间文字private void drawText(Canvas canvas) {mPaint.reset();mPaint.setAntiAlias(true);mPaint.setFakeBoldText(true);Rect textBounds = new Rect();String score = decimalFormat.format(currentScore);mPaint.setTextSize(frontSize);frontColor = ContextCompat.getColor(getContext(),R.color.ScoreCircle_front_color);mPaint.setColor(frontColor);mPaint.getTextBounds(score,0,score.length(),textBounds);canvas.drawText(score,totalSize/2 - textBounds.width()/2 - textBounds.left,totalSize/2 + textBounds.height()/2 - textBounds.bottom  ,mPaint);}

这样就可以画出来,但是还有zu最后一部,保存画过的状态,

 @Nullable@Overrideprotected Parcelable onSaveInstanceState() {Parcelable parcelable = super.onSaveInstanceState();SavedState savedState = new SavedState(parcelable);savedState.SavedCurrentScore = currentScore;return savedState;}private static class SavedState extends BaseSavedState{float SavedCurrentScore;public SavedState(Parcel source) {super(source);SavedCurrentScore = source.readFloat();}public SavedState(Parcelable superState) {super(superState);}@Overridepublic void writeToParcel(Parcel out, int flags) {super.writeToParcel(out, flags);out.writeFloat(SavedCurrentScore);}public static final Creator<SavedState> CREATOR = new Creator<SavedState>(){@Overridepublic SavedState createFromParcel(Parcel source) {return new SavedState(source);}@Overridepublic SavedState[] newArray(int size) {return new SavedState[size];}};}}

这样View重绘的时候状态不会变掉。

http://www.lbrq.cn/news/2486917.html

相关文章:

  • 做网站时量宽度的尺子工具适合seo优化的网站
  • 百度商桥怎么接网站营销策略包括哪些内容
  • 中山市建设局网站产品营销策划方案3000字
  • 自己做的网站为什么访问不互联网广告平台代理
  • 专做立体化的网站谷歌seo一个月费用需要2万吗
  • 建网站权威公司百度问答
  • 网页的网站建设在哪里营销策划与运营公司
  • 哪些网站专门做动漫的深圳知名seo公司
  • 品牌网站建设推广智能建站模板
  • 百度收录网站名字大连网络营销seo
  • 做国外销售都上什么网站启动互联全网营销推广
  • 网上做调查赚钱的网站有哪些域名查询网站信息
  • 法院举报网站建设的要求上海优化网站seo公司
  • 网站域名做固定资产怎么处理佛山seo联系方式
  • 私服网站去哪买空间啊北京网站seo公司
  • 做二手车按揭的网站详情页页面页面
  • 单纯做seo能否提升网站流量东莞疫情最新消息今天又封了
  • 北京建设工程交易网seo刷词
  • 网站建设环保seo的中文含义是什么意思
  • 网站图片轮播怎么弄引流用什么话术更吸引人
  • 岳阳网站制作石家庄新闻网头条新闻
  • 有什么做服装的网站好优化外包服务公司
  • 东莞品牌网站建设学校网站建设哪家好
  • wordpress主题安装后不一样seo网址大全
  • 网站开发机构重庆seo全面优化
  • 定制网站公司哪家好客源软件哪个最好
  • 北京市委宣传部西安百度网站排名优化
  • 宣传册设计及网站建设做网站要多少钱
  • 建网站的重要性百度首页快速排名系统
  • 做视频上传到网站怎么赚钱如何推广一款app
  • DAY21-二叉树的遍历方式
  • 【Qt开发】信号与槽(二)-> 信号和槽的使用
  • Swagger 配置及使用指南
  • 【AI论文】MiroMind-M1:通过情境感知多阶段策略优化实现数学推理的开源新进展
  • xLua和C#交互
  • 泰山派GPIO编译 ADB下载 万用表测量GPIO电压