PieChartView
Android实现Pie Chart(饼状图),可设置为环形图
Install / Use
/learn @luweibin3118/PieChartViewREADME
PieChartView
Android实现Pie Chart(饼状图),可设置为环形图
项目添加依赖: project/build.gradle中添加:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
project/app/build.gradle中添加:
dependencies {
implementation 'com.github.luweibin3118:PieChartView:v1.1.2'
}
-
在布局文件中引入RadarChartView:
<com.lwb.piechart.PieChartView android:id="@+id/pie_chart_view" android:layout_width="match_parent" android:layout_height="match_parent" />
-
Java代码中,通过以下方法添加一条属性:
PieChartView pieChartView = findViewById(R.id.pie_chart_view); pieChartView.addItemType(new PieChartView.ItemType("苹果", 25, 0xff20B2AA)); pieChartView.addItemType(new PieChartView.ItemType("华为", 17, 0xff68228B)); pieChartView.addItemType(new PieChartView.ItemType("小米", 13, 0xff8B5A00)); pieChartView.addItemType(new PieChartView.ItemType("三星", 8, 0xffCD3700)); pieChartView.addItemType(new PieChartView.ItemType("OPPO", 6, 0xff8968CD)); pieChartView.addItemType(new PieChartView.ItemType("VIVO", 5, 0xff437145)); pieChartView.addItemType(new PieChartView.ItemType("魅族", 4, 0xff8DB6CD)); pieChartView.addItemType(new PieChartView.ItemType("联想", 2, 0xff6B8E23)); pieChartView.addItemType(new PieChartView.ItemType("其他品牌", 20, 0xff999999));

-
设置以下方法可平移饼图:
pieChartView.setPieCell(10); // 10 位平移距离大小效果如图:

-
设置以下方法可以实现环形图:
pieChartView.setCell(5); //设置环形图的间距 pieChartView.setInnerRadius(0.4f); //设置环形图内环半径比例 0 - 1.0f

-
其他方法:
pieChartView.setBackGroundColor(0xffFFFFE0); //设置背景颜色 pieChartView.setItemTextSize(30); //设置字体大小 pieChartView.setTextPadding(10); //设置字体与横线距离
Related Skills
node-connect
351.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
