Android 扇形統(tǒng)計圖

先看看效果:
看上去如果覺得還行就繼續(xù)往下看吧!


自定義View
定義成員變量
private int mHeight, mWidth;//寬高
private Paint mPaint;//扇形的畫筆
private Paint mTextPaint;//畫文字的畫筆
private int centerX, centerY;//中心坐標
//"其他"的value
//扇形圖分成太多快 所以要合并一部分為其他 即圖中灰色部分
private double rest;
private int maxNum = 5;//扇形圖的大塊數(shù) 超過的item就合并到其他
String others = "其他";//“其他”塊要顯示的文字
double total;//數(shù)據(jù)的總和
double[] datas;//數(shù)據(jù)集
String[] texts;//每個數(shù)據(jù)對應的文字集
//顏色 默認的顏色
private int[] mColors = {
Color.parseColor("#FF4081"), Color.parseColor("#ffc0cb"),
Color.parseColor("#00ff00"), Color.parseColor("#0066ff"), Color.parseColor("#ffee00")
};
private int mTextSize;//文字大小 單位:像素
private int radius = 1000;//半徑 在畫圖時初始化
分享標題:Android自定義View——扇形統(tǒng)計圖的實現(xiàn)代碼-創(chuàng)新互聯(lián)
本文地址:http://www.chinadenli.net/article34/iejpe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、網(wǎng)站制作、關(guān)鍵詞優(yōu)化、移動網(wǎng)站建設(shè)、服務器托管、建站公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)