自定义View写的TTJPieChart

自定义ViewGroup写的TTJPieChartGroup

公司项目里抽出来的,希望对大家有用,也希望大家多多指教,接下来的时间我会补充讲解如何实现(代码中有很多注释)。

先给大家项目的GitHub链接:https://github.com/15915763299/TTJPieChart


TTJPieChart

改版淘淘金中使用的PieChart

目前 MyPieChartGroup 只支持三个变量的图表,MyPieChart 没有限制。 findView 之后务必要调用 init 方法初始化饼图

使用方法(举例):

xml:

 <...(包名).MyPieChartGroup    android:id="@+id/my_pie_chart_group"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_marginLeft="10dp"    android:background="#ffffff/> <...(包名).MyPieChart    android:id="@+id/my_pie_chart"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_marginLeft="10dp"    android:background="#ffffff/>

java:

  int[] colors = {            R.color.freezing_amount,            R.color.not_receive_principal,            R.color.available_balance  };  float[] numbers = {5, 2, 90};  String[] titles = {           R.string.freezing_amount,           R.string.unreceived_amount,           R.string.avaliable_amount  };
  // my_pie_chart_group  MyPieChartGroup my_pie_chart_group = (MyPieChartGroup) findViewById(R.id.my_pie_chart_group);  // 第一个参数为 titles 字体的大小,  单位:sp  my_pie_chart_group.init(12, titles, colors, numbers);  // my_pie_chart  MyPieChart my_pie_chart = (MyPieChart) findViewById(R.id.my_pie_chart);  //  第一个参数为饼图半径,  第二个参数为饼图圆弧宽度, 单位都为dip  my_pie_chart.initChart(65, 25, colors, numbers);  my_pie_chart.setStartPosition(180);

效果图:(橙色线条为测试的时候画上去的,代码中已注释掉)



更多相关文章

  1. Android(安卓)Studio Error—Gradle: 错误:编码 GBK 的不可映射
  2. Android中的长度单位
  3. Android签名过程
  4. Android中Message传递参数实例
  5. 对android:textAlignmentStyle 属性参数的理解
  6. 纯Java代码写登录注册页面
  7. 语音识别(加注释)
  8. 自定义Dialog位置和大小
  9. 使用View绘制虚线时demo,方便复习

随机推荐

  1. 学Python需要多久?应用领域有哪些?
  2. 02-K8s部署安装配置 Kuboard v2
  3. 9.6 C++指向结构体变量的指针
  4. Rust Meetup 登陆深圳,满满的都是干货!
  5. 《商君书》白话解读 10章 战法
  6. 五款Python图像处理工具!Python入门分享!
  7. 一杯茶的功夫,上手Redis持久化机制
  8. 2021年哪些办公软件比较好用?
  9. 《商君书》白话翻译与解读——15章 徕民
  10. 《商君书》白话解读——14章 修权