日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

android實(shí)現(xiàn)簡(jiǎn)單儀表盤效果

瀏覽:45日期:2022-09-18 13:36:17

本文實(shí)例為大家分享了android實(shí)現(xiàn)簡(jiǎn)單儀表盤效果的具體代碼,供大家參考,具體內(nèi)容如下

實(shí)現(xiàn)這個(gè)效果:

android實(shí)現(xiàn)簡(jiǎn)單儀表盤效果

中間的文字很好寫(xiě),外層的進(jìn)度條就需要自定義控件了,代碼如下:

public class CirCleProgressBar extends View { private Paint circlePaint; private Paint textPaint; private int circleColor;//圓弧顏色 private int circleBgColor;//圓弧背景顏色 private float circleWidth;//圓弧寬度 private float circleBgWidth;//圓弧背景寬度 private int textColor;//字體顏色 private float textSize;//字體大小 private int totalAngle;//總角度 private int startAngle;//開(kāi)始角度 private float currentProgress;//當(dāng)前進(jìn)度 private float maxProgress;//最大進(jìn)度 private float section;//分段 private float currentAngle;//當(dāng)前角度 private float lastAngle; private ValueAnimator progressAnimator;//圓弧動(dòng)畫(huà) private int duration = 1000;//動(dòng)畫(huà)時(shí)長(zhǎng) private boolean isDefaultText;//是否設(shè)置文字顯示的值 private String mTextValue;//字體顯示的值 public CirCleProgressBar(Context context) {this(context, null); } public CirCleProgressBar(Context context, AttributeSet attrs) {this(context, attrs, 0); } public CirCleProgressBar(Context context, AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);circlePaint = new Paint();textPaint = new Paint();TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CirCleProgressBar);circleColor = typedArray.getColor(R.styleable.CirCleProgressBar_circle_color, Color.RED);circleBgColor = typedArray.getColor(R.styleable.CirCleProgressBar_circle_bg_color, Color.YELLOW);circleWidth = typedArray.getDimension(R.styleable.CirCleProgressBar_circle_width, 2);circleBgWidth = typedArray.getDimension(R.styleable.CirCleProgressBar_circle_bg_width, 2);textColor = typedArray.getColor(R.styleable.CirCleProgressBar_text_color, Color.BLUE);textSize = typedArray.getDimension(R.styleable.CirCleProgressBar_text_size, 10);totalAngle = typedArray.getInteger(R.styleable.CirCleProgressBar_total_angle, 360);startAngle = typedArray.getInteger(R.styleable.CirCleProgressBar_start_angle, 0);currentProgress = typedArray.getFloat(R.styleable.CirCleProgressBar_current_progress, 0);maxProgress = typedArray.getFloat(R.styleable.CirCleProgressBar_max_progress, 100);setCurrentProgress(currentProgress);setMaxProgress(maxProgress);//typedArray.recycle(); } @SuppressLint('DrawAllocation') @Override protected void onDraw(Canvas canvas) {super.onDraw(canvas);/** * 畫(huà)最外層的大圓環(huán) */int centre = getWidth() / 2; // 獲取圓心的x坐標(biāo)int radius = (int) (centre - circleWidth / 2) - 2; // 圓環(huán)的半徑circlePaint.setColor(circleBgColor);circlePaint.setStyle(Paint.Style.STROKE);circlePaint.setAntiAlias(true);circlePaint.setStrokeCap(Paint.Cap.ROUND);// 圓頭circlePaint.setStrokeWidth(circleBgWidth);RectF oval = new RectF(centre - radius - 1, centre - radius - 1, centre + radius + 1, centre + radius + 1); // 用于定義的圓弧的形狀和大小的界限//背景圓canvas.drawArc(oval, startAngle, totalAngle, false, circlePaint);//數(shù)據(jù)圓circlePaint.setStrokeWidth(circleWidth);circlePaint.setColor(circleColor);canvas.drawArc(oval, startAngle, currentAngle, false, circlePaint);//textPaint.setAntiAlias(true);textPaint.setColor(textColor);textPaint.setTextSize(textSize);float textWidth = textPaint.measureText((int) currentProgress + '');if(!isDefaultText) { canvas.drawText(String.valueOf((int)currentProgress), centre - textWidth / 2, centre + textSize / 2, textPaint);}else { canvas.drawText(mTextValue, centre - textWidth / 2, centre + textSize / 2, textPaint);}//invalidate(); } public float getMaxProgress(){return maxProgress; } public void setMaxProgress(float maxProgress){if(maxProgress < 0){ throw new IllegalArgumentException('max not less than 0');}this.maxProgress = maxProgress;section = totalAngle / maxProgress; } public void setAnimationDuration(int duration){this.duration = duration; } public void setCurrentProgress(float progress){if(progress >= 0){ this.currentProgress = progress; if(progress > maxProgress){progress = maxProgress; } lastAngle = currentAngle; setAnimation(lastAngle, progress * section, duration);} } private void setAnimation(float last, float current, int duration){progressAnimator = ValueAnimator.ofFloat(last, current);progressAnimator.setDuration(duration);progressAnimator.setTarget(currentAngle);progressAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) {currentAngle = (float) valueAnimator.getAnimatedValue();currentProgress = currentAngle / section; }});progressAnimator.start(); } public int getCircleColor() {return circleColor; } public void setCircleColor(int circleColor) {this.circleColor = circleColor; } public int getCircleBgColor() {return circleBgColor; } public void setCircleBgColor(int circleBgColor) {this.circleBgColor = circleBgColor; } public float getCircleWidth() {return circleWidth; } public void setCircleWidth(float circleWidth) {this.circleWidth = circleWidth; } public float getCircleBgWidth() {return circleBgWidth; } public void setCircleBgWidth(float circleBgWidth) {this.circleBgWidth = circleBgWidth; } public int getTextColor() {return textColor; } public void setTextColor(int textColor) {this.textColor = textColor; } public float getTextSize() {return textSize; } public void setTextSize(float textSize) {this.textSize = textSize; } /** * @param isText 為true,自定義設(shè)置字體顯示 * @param text */ public void setText(boolean isText,String text){isDefaultText = isText;mTextValue = text; }}

需要在attrs中添加:

<declare-styleable name='CirCleProgressBar'><attr name='circle_color' format='color'/><attr name='circle_bg_color' format='color'/><attr name='circle_width' format='dimension'/><attr name='circle_bg_width' format='dimension'/><attr name='text_color' format='color'/><attr name='text_size' format='dimension'/><attr name='total_angle' format='integer'/><attr name='start_angle' format='integer'/><attr name='current_progress' format='float'/><attr name='max_progress' format='float'/></declare-styleable>

使用方法:

在布局文件中直接引用

<com.fm.newcinema.view.CirCleProgressBarandroid: android:layout_width='139dp'android:layout_height='99dp'android:layout_gravity='center_horizontal'android:layout_marginTop='8dp'app:circle_bg_color='@color/gray_line_ff'app:circle_bg_width='10dp'app:circle_color='@color/main_blue'app:circle_width='10dp'app:max_progress='100'app:start_angle='160'app:text_color='@color/white_ff'app:text_size='@dimen/size_30px'app:total_angle='221'/>

其中app:circle_bg_color表示進(jìn)度條底層的顏色,app:circle_color表示進(jìn)度條上層的顏色,app:circle_bg_width表示進(jìn)度條底層的寬度,app:circle_width表示進(jìn)度條上層的寬度,app:max_progress='100'表示進(jìn)度條最大進(jìn)度是100,app:start_angle表示開(kāi)始的角度,就是進(jìn)度條從哪個(gè)角度開(kāi)始畫(huà),如下圖所示

android實(shí)現(xiàn)簡(jiǎn)單儀表盤效果

app:total_angle表示整個(gè)進(jìn)度條所需的角度.在代碼中設(shè)置旋轉(zhuǎn)的角度,圖中進(jìn)度為30%,由于在布局文件中設(shè)置的最大進(jìn)度是100`app:max_progress='100',所以進(jìn)行如下設(shè)置peocess.setCurrentProgress(30f)默認(rèn)情況下,進(jìn)度條中間顯示進(jìn)度條的值,如果需要自己寫(xiě)值的畫(huà),調(diào)用這個(gè)方法:process.setText(true, '中間的字');

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Android
相關(guān)文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
日韩欧美另类一区二区| 国产视频一区三区| 成人小电影网站| 蜜桃成人av| 毛片在线网站| 亚洲激情久久| 1024精品一区二区三区| 欧美日韩国产传媒| 国产精品国产一区| 一区二区三区四区日韩| 日韩免费精品| 欧美日韩亚洲一区| 美女视频黄 久久| 另类欧美日韩国产在线| 国产白浆在线免费观看| av免费不卡国产观看| 国产一区二区精品福利地址| 久久精品中文| 国产日韩亚洲| 日韩精品中文字幕吗一区二区| 日本va欧美va欧美va精品| 日韩av影院| 久久精品99久久久| 日韩中文字幕在线一区| 国产精品扒开腿做爽爽爽软件| 久久精品国内一区二区三区| 精品日韩毛片| 伊人网在线播放| 国产日韩欧美一区| 亚洲性视频在线| 日本成人中文字幕在线视频| 欧美一级网站| 国产aa精品| 狠狠久久伊人| 亚洲播播91| 国产精品88久久久久久| 亚洲视频电影在线| 99国产精品视频免费观看一公开| 久久av网站| 亚洲性色视频| 97在线精品| 国产精品最新| 国产精品3区| 欧美激情日韩| 午夜在线视频一区二区区别| 香蕉人人精品| 精品在线91| 亚洲一级少妇| 伊人久久视频| 色婷婷精品视频| 91视频一区| 欧洲在线一区| 亚洲午夜视频| 欧美专区一区二区三区| 五月精品视频| 亚洲永久字幕| 美日韩一区二区三区| 久久99视频| 精品免费av一区二区三区| 国产传媒在线观看| 久久国产日韩| 色综合www| 国产欧美日韩亚洲一区二区三区| 麻豆久久久久久| 丝袜国产日韩另类美女| 日韩欧美视频专区| 国产精区一区二区| 日韩午夜精品| 99久精品视频在线观看视频| 国产精品一区二区99| 国产毛片一区| 欧美不卡视频| 精品欧美一区二区三区在线观看| 国产精品高清一区二区| 国产精品nxnn| 日韩福利视频导航| 999在线观看精品免费不卡网站| 免费福利视频一区二区三区| 日本一区福利在线| 麻豆亚洲精品| 性欧美精品高清| 午夜在线视频一区二区区别| 在线 亚洲欧美在线综合一区| 欧美一区二区三区激情视频| 久久精品观看| 久久久久久久久99精品大| 欧美丰满日韩| 久久久久99| 日日夜夜免费精品视频| 国产亚洲精品美女久久久久久久久久| 久久精品二区亚洲w码| 91成人在线| 91免费精品国偷自产在线在线| 日韩午夜av| 91精品一区二区三区综合| 国产精品99久久免费观看| 国产日韩欧美在线播放不卡| 日本视频一区二区| 先锋亚洲精品| 黄色不卡一区| 国产精品乱战久久久| 日韩精品永久网址| 婷婷五月色综合香五月| 国产日韩在线观看视频| 久久精选视频| 久久精品国产99国产| 亚洲欧美日韩视频二区| 国产美女视频一区二区| 久久香蕉网站| 亚洲欧美视频一区二区三区| 精品亚洲自拍| 午夜久久影院| 狂野欧美性猛交xxxx| 亚洲午夜黄色| 久久精品资源| 亚洲网址在线观看| 桃色一区二区| 奇米777国产一区国产二区| 国产乱论精品| 欧美日韩一区二区国产 | 亚洲开心激情| 中文国产一区| 国产精品一区二区中文字幕| 999国产精品视频| 国产日韩一区二区三区在线 | 水蜜桃精品av一区二区| 青青草国产成人99久久| 黄色亚洲在线| 国产成人精品一区二区三区免费 | 久久久久网站| 国产精品一国产精品| yellow在线观看网址| 青青国产91久久久久久| 午夜一区在线| 99国产成+人+综合+亚洲欧美| 麻豆一区在线| 欧美一区影院| 欧美少妇精品| 国产探花在线精品| 日韩一区二区中文| 亚洲人成高清| 久久av在线| 亚洲免费黄色| 欧美日韩精品免费观看视频完整| 亚洲精品123区| 日韩av免费大片| 国产精品亚洲人成在99www| 亚洲男人在线| 欧美日韩国产一区精品一区| 精品中国亚洲| 日韩在线观看中文字幕| 久久精品青草| 日本强好片久久久久久aaa| 国产日韩免费| 日韩激情啪啪| 久久久久久美女精品| 欧美精品黄色| 亚洲综合日韩| 亚洲无线一线二线三线区别av| 日韩中文影院| 亚洲欧美久久久| 石原莉奈在线亚洲三区| 亚洲开心激情| 奇米亚洲欧美| 精品一区二区三区四区五区| 精品国产亚洲一区二区三区在线 | 欧美高清不卡| 欧美日韩亚洲一区二区三区在线| 中文字幕在线官网| 国产视频一区免费看| 国产精品手机在线播放| 国产精品综合色区在线观看| 蜜桃久久久久| 九九综合九九| 青青国产精品| 色在线中文字幕| 中文在线日韩| 视频在线不卡免费观看| 爽好久久久欧美精品| 久久超碰99| 在线看片不卡| 国产欧美日韩精品一区二区免费| 福利一区和二区| 蜜桃视频免费观看一区| 国产精品一区二区免费福利视频| 亚洲播播91| 亚洲国产影院| 欧美精选视频一区二区| 国产欧美日韩精品一区二区免费| 欧美中文一区| 国产欧美一区二区色老头| 精品亚洲a∨| 98精品久久久久久久| 国产一区国产二区国产三区| 麻豆精品视频在线| 国语精品一区| 国产不卡精品在线| 精品视频国产| 在线人成日本视频| 国产极品一区|