<Android 进阶(二)> 自定义View之Dota2能力雷达图
来源:互联网 发布:软件测试简单吗 编辑:程序博客网 时间:2024/05/17 06:24
1. 前言
最近看Dota2的比赛的时候无意在一个应用中看到来一个能力分析的雷达图,就是展示你的各方面数据。你可能看见过这个图。
2. 实现思路
- 继承View,复写onDraw。
- 确定N边形和每个边对应的角度;
- 确定多边形外接圆的半径以及圆心(也就是中心点)
- 确定每条半径上的所有点的坐标。
- 确定每条数据在图形上的坐标;
- 确定文字在图形上的位置;
- 采用合适的绘制方式绘制;
3. 实现
3.1 定义自定义属性
主要定义这几个属性,可以根据需要继续扩展。
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
3.2 自定义View代码
注释代码中都有写出来,主要是看下实现的方式。没有过多的修饰和精简。
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
- 225
- 226
- 227
- 228
- 229
- 230
- 231
- 232
- 233
- 234
- 235
- 236
- 237
- 238
- 239
- 240
- 241
- 242
- 243
- 244
- 245
- 246
- 247
- 248
- 249
- 250
- 251
- 252
- 253
- 254
- 255
- 256
- 257
- 258
- 259
- 260
- 261
- 262
- 263
- 264
- 265
- 266
- 267
- 268
- 269
- 270
- 271
- 272
- 273
- 274
- 275
- 276
- 277
- 278
- 279
- 280
- 281
- 282
- 283
- 284
- 285
- 286
- 287
- 288
- 289
- 290
- 291
- 292
- 293
- 294
- 295
- 296
- 297
- 298
- 299
- 300
- 301
- 302
- 303
- 304
- 305
- 306
- 307
- 308
- 309
- 310
- 311
- 312
- 313
- 314
- 315
- 316
- 317
- 318
- 319
- 320
- 321
- 322
- 323
- 324
- 325
- 326
可能画图过程中的实现方式优点粗糙,大家可以根据自己的方式,改写即可。
个人是先将每条半径上的端点全部计算出来进行保存,然后一次连接,然后把每个半径首尾端点连接,然后绘制覆盖区域,覆盖区域也是采用先计算点位置,然后连接的方式实现,最后确定文本的显示位置和文字的绘制。由于这里涉及到绘制换行文字,使用到来StaticLayout。使用方法请查阅对应API。
4. 效果
5. 源码
源码依然是上传到Github
http://www.chengshiluntan.com/6917210-1.html
http://www.chengshiluntan.com/6917406-1.html
http://www.chengshiluntan.com/6917415-1.html
http://www.chengshiluntan.com/6917442-1.html
http://www.chengshiluntan.com/6917466-1.html
http://www.chengshiluntan.com/6917478-1.html
http://www.chengshiluntan.com/6917498-1.html
http://www.chengshiluntan.com/6917537-1.html
http://www.chengshiluntan.com/6917590-1.html
http://www.chengshiluntan.com/6917604-1.html
http://baijiahao.baidu.com/builder/preview/s?id=1582026938020897352
http://baijiahao.baidu.com/builder/preview/s?id=1582039159015647408
http://baijiahao.baidu.com/builder/preview/s?id=1582039360113121208
http://baijiahao.baidu.com/builder/preview/s?id=1582039573322455310
http://baijiahao.baidu.com/builder/preview/s?id=1582039718004335961
http://baijiahao.baidu.com/builder/preview/s?id=1582039909318708132
http://www.19lou.com/board-73061508556280516-thread-76581508739143051-1.htm
https://www.wang1314.com/doc/topic-6657294-1.html
https://www.wang1314.com/doc/topic-6658374-1.html
https://www.wang1314.com/doc/topic-6658633-1.html
https://www.wang1314.com/doc/topic-6658924-1.html
https://www.wang1314.com/doc/topic-6659557-1.html
https://www.wang1314.com/doc/topic-6659680-1.html
https://www.wang1314.com/doc/topic-6659864-1.html
https://www.wang1314.com/doc/topic-6660005-1.html
https://www.wang1314.com/doc/topic-6660666-1.html
https://www.wang1314.com/doc/topic-6609646-1.html
http://www.51sole.com/b2b/sides126186361.html
http://www.51sole.com/b2b/sides126186624.html
http://www.51sole.com/b2b/sides126186686.html
http://www.51sole.com/b2b/sides126186772.html
http://www.51sole.com/b2b/sides126187022.html
http://www.51sole.com/b2b/sides126187055.html
http://www.51sole.com/b2b/sides126187096.html
http://www.51sole.com/b2b/sides126187127.html
http://www.51sole.com/b2b/sides126187238.html
http://www.51sole.com/b2b/sides126187266.html
http://blog.sina.com.cn/s/blog_17baa4f330102wxv6.html
http://blog.sina.com.cn/s/blog_17baa4f330102wxv9.html
http://blog.sina.com.cn/s/blog_17baa4f330102wxva.html
http://blog.sina.com.cn/s/blog_17baa4f330102wxvb.html
http://blog.sina.com.cn/s/blog_17baa4f330102wxvd.html
http://blog.sina.com.cn/s/blog_17b5382a20102xthd.html
http://blog.sina.com.cn/s/blog_17b5382a20102xthi.html
http://blog.sina.com.cn/s/blog_17b5382a20102xthl.html
http://blog.sina.com.cn/s/blog_17b5382a20102xthn.html
http://blog.sina.com.cn/s/blog_17b5382a20102xthp.html
http://groups.tianya.cn/post-224172-51ccfde5bf8e4da393a9474a082b7c74-1.shtml
https://club.1688.com/article/63153589.html
https://club.1688.com/article/63153762.html
https://club.1688.com/article/63154090.html
https://tieba.baidu.com/p/5386469825
https://tieba.baidu.com/p/5386471541
https://tieba.baidu.com/p/5386475851
https://tieba.baidu.com/p/5386482872
https://tieba.baidu.com/p/5386484224
https://tieba.baidu.com/p/5386490335
https://tieba.baidu.com/p/5386491309
http://www.chengshiluntan.com/6915808-1.html
http://www.chengshiluntan.com/6915825-1.html
http://www.chengshiluntan.com/6915841-1.html
http://www.chengshiluntan.com/6915852-1.html
http://www.chengshiluntan.com/6915856-1.html
http://www.chengshiluntan.com/6915865-1.html
http://www.chengshiluntan.com/6915871-1.html
http://www.chengshiluntan.com/6915876-1.html
http://www.chengshiluntan.com/6915878-1.html
http://www.chengshiluntan.com/6915882-1.html
https://www.wang1314.com/doc/topic-6606626-1.html
https://www.wang1314.com/doc/topic-6606845-1.html
https://www.wang1314.com/doc/topic-6607270-1.html
https://www.wang1314.com/doc/topic-6607756-1.html
https://www.wang1314.com/doc/topic-6607841-1.html
https://www.wang1314.com/doc/topic-6608214-1.html
https://www.wang1314.com/doc/topic-6608745-1.html
https://www.wang1314.com/doc/topic-6609028-1.html
https://www.wang1314.com/doc/topic-6609303-1.html
https://www.wang1314.com/doc/topic-6609646-1.html
http://www.19lou.com/board-49041508472050881-thread-48631508640211455-1.html
https://buluo.qq.com/p/detail.html?bid=329211&pid=1242779-1508657617
http://blog.csdn.net/wonderfulwyq991/article/details/78310152
http://blog.csdn.net/sprite12io12/article/details/78310178
http://blog.sina.com.cn/s/blog_17b5382a20102xtg9.html
http://blog.sina.com.cn/s/blog_17b5382a20102xtg8.html
http://blog.sina.com.cn/s/blog_17b5382a20102xtga.html
http://blog.sina.com.cn/s/blog_17b5382a20102xtgb.html
http://blog.sina.com.cn/s/blog_17b5382a20102xtgc.html
http://blog.sina.com.cn/s/blog_17baa4f330102wxsx.html
http://blog.sina.com.cn/s/blog_17baa4f330102wxsy.html
http://blog.sina.com.cn/s/blog_17baa4f330102wxsz.html
http://blog.sina.com.cn/s/blog_17baa4f330102wxt0.html
http://blog.sina.com.cn/s/blog_17baa4f330102wxt1.html
https://club.1688.com/threadview/49696723.htm
https://club.1688.com/threadview/49696750.htm
https://club.1688.com/threadview/49696758.htm
https://club.1688.com/threadview/49696768.htm
http://baijiahao.baidu.com/builder/preview/s?id=1581948825320626187
http://baijiahao.baidu.com/builder/preview/s?id=1581949373717418375
http://baijiahao.baidu.com/builder/preview/s?id=1581949504752257022
http://baijiahao.baidu.com/builder/preview/s?id=1581949628525014624
http://baijiahao.baidu.com/builder/preview/s?id=1581949794692411463
http://baijiahao.baidu.com/builder/preview/s?id=1581950036340781106
https://tieba.baidu.com/p/5385005459
https://tieba.baidu.com/p/5385095696
https://www.douban.com/note/641935862/
https://www.19lou.com/board-56081508570206074-thread-56241508570579468-1.html
https://www.19lou.com/board-56081508570206074-thread-56351508571299964-1.html
https://www.19lou.com/wap/board-56081508570206074-thread-48391508572110589-1.html
https://www.19lou.com/board-56091508570886242-thread-56571508586179505-1.html
https://www.19lou.com/board-56091508570886242-thread-53921508590662025-1.html
https://www.19lou.com/wap/board-48121508590547628-thread-73551508590711589-1.html
http://www.19lou.com/board-48061508479844091-thread-56961508555784191-1.html
http://www.19lou.com/board-48061508479844091-thread-56451508556735798-1.html
http://www.19lou.com/board-48061508479844091-thread-56271508558579911-1.html
http://www.19lou.com/board-48061508479844091-thread-56561508561871011-1.html
http://taizhou.19lou.com/board-49081508556617184-thread-53171508556828094-1.html
http://taizhou.19lou.com/board-49081508556617184-thread-53961508564806973-1.html
http://taizhou.19lou.com/board-49081508556617184-thread-53181508566578551-1.html
http://taizhou.19lou.com/board-49081508556617184-thread-53401508568058642-1.html
http://taizhou.19lou.com/board-49081508556617184-thread-53121508571881462-1.html
http://taizhou.19lou.com/board-49081508556617184-thread-53581508573216301-1.html
http://taizhou.19lou.com/board-49081508556617184-thread-53601508573369685-1.html
http://taizhou.19lou.com/board-49081508556617184-thread-53621508573529197-1.html
http://taizhou.19lou.com/board-49081508556617184-thread-53671508573749530-1.html
http://taizhou.19lou.com/board-49081508556617184-thread-53731508573970612-1.html
https://www.douban.com/note/641934310/
https://www.douban.com/note/641934119/
https://www.douban.com/note/641934401/
http://www.19lou.com/board-73061508556280516-thread-49341508573298850-1.html
http://www.19lou.com/board-73061508556280516-thread-49821508572317344-1.html
http://www.19lou.com/board-73061508556280516-thread-49531508571648305-1.html
http://www.19lou.com/board-73061508556280516-thread-49501508571346263-1.html
http://www.19lou.com/board-73061508556280516-thread-49481508566877867-1.html
http://www.19lou.com/board-73061508556280516-thread-49361508565965149-1.html
http://www.19lou.com/board-73061508556280516-thread-49281508565418274-1.html
http://www.19lou.com/board-73061508556280516-thread-49941508556806027-1.html
http://www.19lou.com/board-73061508556280516-thread-49871508556671497-1.html
http://www.19lou.com/board-73061508556280516-thread-49751508556417484-1.html
https://www.wang1314.com/doc/topic-6578555-1.html
https://www.wang1314.com/doc/topic-6579098-1.html
https://www.wang1314.com/doc/topic-6579547-1.html
https://www.wang1314.com/doc/topic-6579708-1.html
https://www.wang1314.com/doc/topic-6579918-1.html
https://www.wang1314.com/doc/topic-6581520-1.html
https://www.wang1314.com/doc/topic-6581695-1.html
https://www.wang1314.com/doc/topic-6585393-1.html
https://www.wang1314.com/doc/topic-6585468-1.html
https://www.wang1314.com/doc/topic-6585531-1.html
http://dy.163.com/v2/article/detail/D19L662A0523LCR7.html
http://dy.163.com/v2/article/detail/D19MRC0Q0517MR88.html
http://dy.163.com/v2/article/detail/D19N7R8A0523LCR7.html
http://dy.163.com/v2/article/detail/D19NSPJ40523LCR7.html
http://dy.163.com/v2/article/detail/D19O6SQE0517MQQ2.html
http://dy.163.com/v2/article/detail/D19ON61R0517MQQ2.html
http://dy.163.com/v2/article/detail/D19PGPM00517MQQ2.html
http://dy.163.com/v2/article/detail/D19PNBCP0517MQQ2.html
http://dy.163.com/v2/article/detail/D19UD4830517MQQ2.html
http://blog.sina.com.cn/s/blog_17b52c5a90102xnyf.html
http://blog.sina.com.cn/s/blog_17b52c5a90102xnyg.html
http://blog.sina.com.cn/s/blog_17b52c5a90102xnyi.html
http://blog.sina.com.cn/s/blog_17b52c5a90102xnyj.html
http://blog.sina.com.cn/s/blog_17b52c5a90102xnyk.html
http://blog.sina.com.cn/s/blog_17b539da20102xdfe.html
http://blog.sina.com.cn/s/blog_17b539da20102xdff.html
http://blog.sina.com.cn/s/blog_17b539da20102xdfg.html
http://blog.sina.com.cn/s/blog_17b539da20102xdfh.html
http://blog.sina.com.cn/s/blog_17b539da20102xdfn.html
https://buluo.qq.com/p/detail.html?bid=329211&pid=1242779-1508657617
http://www.chengshiluntan.com/6914932-1.html
http://www.chengshiluntan.com/6914984-1.html
http://www.chengshiluntan.com/6915011-1.html
http://www.chengshiluntan.com/6915016-1.html
http://www.chengshiluntan.com/6915023-1.html
http://www.chengshiluntan.com/6915100-1.html
http://www.chengshiluntan.com/6915106-1.html
http://www.chengshiluntan.com/6915118-1.html
http://www.chengshiluntan.com/6915134-1.html
http://www.19lou.com/board-49041508472050881-thread-48701508556947506-1.html
http://www.19lou.com/board-49041508472050881-thread-53791508570448292-1.html
http://www.chengshiluntan.com/6911287-1.html
http://www.chengshiluntan.com/6911538-1.html
http://www.chengshiluntan.com/6911778-1.html
http://www.chengshiluntan.com/6911782-1.html
https://www.wang1314.com/doc/topic-6454177-1.html
https://www.wang1314.com/doc/topic-6454648-1.html
https://www.wang1314.com/doc/topic-6454954-1.html
https://www.wang1314.com/doc/topic-6455395-1.html
https://www.wang1314.com/doc/topic-6458085-1.html
https://www.wang1314.com/doc/topic-6458362-1.html
https://www.wang1314.com/doc/topic-6458636-1.html
https://www.wang1314.com/doc/topic-6458806-1.html
https://www.wang1314.com/doc/topic-6459305-1.html
https://www.wang1314.com/doc/topic-6459504-1.html
http://www.sohu.com/a/198856653_100034855
http://www.sohu.com/a/198861115_100034855
https://www.3566t.com/sell/s10667341.html
https://club.1688.com/threadview/49690686.htm
http://www.chengshiluntan.com/6907965-1.html
https://www.wang1314.com/doc/topic-6395405-1.html
https://www.wang1314.com/doc/topic-6395618-1.html
https://www.wang1314.com/doc/topic-6395832-1.html
https://www.wang1314.com/doc/topic-6396078-1.html
https://www.wang1314.com/doc/topic-6396251-1.html
https://www.wang1314.com/doc/topic-6397065-1.html
https://www.wang1314.com/doc/topic-6397173-1.html
https://www.wang1314.com/doc/topic-6397294-1.html
https://www.wang1314.com/doc/topic-6397416-1.html
http://www.sohu.com/a/198612284_100034855
http://www.sohu.com/a/198616261_100034855
http://www.sohu.com/a/198619084_100034855
https://club.1688.com/threadview/49686645.htm
https://club.1688.com/threadview/49686783.htm
https://club.1688.com/threadview/49686957.htm
http://www.99inf.com/zyfw/ybsw/5344538.html
http://blog.sina.com.cn/s/blog_17b5382a20102xt9a.html
http://blog.sina.com.cn/s/blog_17b5382a20102xt99.html
http://blog.sina.com.cn/s/blog_17b5382a20102xt9d.html
http://blog.sina.com.cn/s/blog_17baa4f330102wxmv.html
http://blog.sina.com.cn/s/blog_17baa4f330102wxmy.html
http://blog.sina.com.cn/s/blog_17baa4f330102wxn0.html
http://blog.sina.com.cn/s/blog_17baa4f330102wxn3.html
http://blog.sina.com.cn/s/blog_17baa4f330102wxn5.html
http://blog.tianya.cn/post-7664061-129236581-1.shtml
http://blog.tianya.cn/post-7664061-129236622-1.shtml
http://blog.tianya.cn/post-7664061-129236631-1.shtml
http://blog.tianya.cn/post-7664061-129236635-1.shtml
http://blog.tianya.cn/post-7664061-129236678-1.shtml
- <Android 进阶(二)> 自定义View之Dota2能力雷达图
- <Android 进阶(二)> 自定义View之Dota2能力雷达图
- 自定义View能力雷达图
- Android进阶之自定义view(二)
- 【Android进阶之自定义View(二)】
- Android自定义View之微信雷达
- Android自定义View之微信雷达
- Android自定义View(二)进阶
- Android开发,自定义View(二)-----进阶
- Android 自定义View练习:雷达图(比重)绘制
- Android 自定义View( 雷达扫描)
- Android 自定义View (二) 进阶
- Android 自定义View (二) 进阶
- Android 自定义View (二) 进阶
- Android 自定义View (二) 进阶
- Android 自定义View (二) 进阶
- Android 自定义View (二) 进阶
- Android 自定义View (二) 进阶
- 【Nginx+Keepalived】组建高可用负载平衡Web server集群
- C和C++中标准输入中遇到的问题
- Educational Codeforces Round 28 题解
- 【DFS】NOIP2014Day1T2[联合权值]题解
- 【2014acm西安现场赛】K
- <Android 进阶(二)> 自定义View之Dota2能力雷达图
- 算法设计 第二次上机 Subway
- SQL中 % ,_,【】,【^】通配符的的使用
- 董付国老师6本Python系列图书阅读指南
- [xor最小生成树 分治 字典树合并] BNUOJ52318 Be Friends
- Windows环境下nDPI编译调试
- 如何用3升和5升桶量取4升水?
- python基础(3) 匿名函数和文件处理、异常
- cyclicBarrier