文件名称:
Android图表绘制(柱状图、圆形图、折线图)
开发工具:
文件大小: 994kb
下载次数: 0
上传时间: 2014-12-31
详细说明: 利用自定义View层实现柱状图、圆形图、折线图的图表绘制,可以运用在一些评分统计类的App功能中。 public class HomeArc extends View { private Paint paint_black, paint_white; private RectF rectf; private float tb; private int blackColor = 0x70000000; // 底黑色 private int whiteColor = 0xddffffff; // 白色 private int score; private float arc_y = 0f; private int score_text; public HomeArc(Context context, int score) { super(context); init(score); } public void init(int score) { this.score = score; Reso urces res = getResources(); tb = res.getDimension(R.dimen.historyscore_tb); paint_black = new Paint(); paint_black.setAntiAlias(true); paint_black.setColor(blackColor); paint_black.setStrokeWidth(tb * 0.2f); paint_black.setStyle(Style.STROKE); paint_white = new Paint(); paint_white.setAntiAlias(true); paint_white.setColor(whiteColor); paint_white.setTextSize(tb*6.0f); paint_white.setStrokeWidth(tb * 0.2f); paint_white.setTextAlign(Align.CENTER); paint_white.setStyle(Style.STROKE); rectf = new RectF(); rectf.set(tb * 0.5f, tb * 0.5f, tb * 18.5f, tb * 18.5f); setLayoutParams(new LayoutParams((int) (tb * 19.5f), (int) (tb * 19.5f))); this.getViewTreeObserver().addOnPreDrawListener( new OnPreDrawListener() { public boolean onPreDraw() { new thread(); getViewTreeObserver().removeOnPreDrawListener(this); return false; } }); } protected void onDraw(Canvas c) { super.onDraw(c); c.drawArc(rectf, -90, 360, false, paint_black); c.drawArc(rectf, -90, arc_y, false, paint_white); c.drawText("" + score_text, tb * 9.7f, tb * 11.0f, paint_white); } class thread implements Runnable { private Thread thread; private int statek; int count; public thread() { thread = new Thread(this); thread.start(); } public void run() { while (true) { switch (statek) { case 0: try { Thread.sleep(200); statek = 1; } catch (InterruptedException e) { } break; case 1: try { Thread.sleep(15); arc_y += 3.6f; score_text++; count++; postInvalidate(); } catch (InterruptedException e) { e.printStackTrace(); } break; } if (count >= score) break; } } } } ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.