问题
I am working on a project where I want to show a pie chart like the image added. Already have searched google and other posts in stackoverflow, but could not find a solution. any solution is appreciated.
Note: suggestions of third-party library are also welcome. Also please do not suggest MPAndroidChart as I think my query can be implemented using simpler method.
回答1:
You can use the library https://github.com/PhilJay/MPAndroidChart to achieve this.
Add below in xml:
<com.github.mikephil.charting.charts.PieChart
android:id="@+id/chart"
android:layout_width="match_parent"
android:layout_height="match_parent" />
In java code:
PieChart chart = (Piechart) findViewById(R.id.chart);
Example code:
https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/PieChartActivity.java
There are lot of variances available.
Another library to consider is:
https://github.com/lecho/hellocharts-android
回答2:
You can also use this library - https://github.com/lzyzsd/CircleProgress
I found it be much simpler to use and easier to customise in comparison to the more complex chart libraries like MPChart.
来源:https://stackoverflow.com/questions/34824653/creating-pie-chart-progressbar-like-arc-in-andorid