@@ -22,28 +22,37 @@ public class MainActivity extends AppCompatActivity {
2222 protected void onCreate (Bundle savedInstanceState ) {
2323 super .onCreate (savedInstanceState );
2424 setContentView (R .layout .activity_main );
25+ getSupportActionBar ().hide ();
2526 mRadarView = (RadarView ) findViewById (R .id .radarView );
27+
2628 mRadarView .setEmptyHint ("无数据" );
29+
2730 List <Integer > layerColor = new ArrayList <>();
2831 Collections .addAll (layerColor , 0x3300bcd4 , 0x3303a9f4 , 0x335677fc , 0x333f51b5 , 0x33673ab7 );
2932 mRadarView .setLayerColor (layerColor );
33+
3034 List <String > vertexText = new ArrayList <>();
3135 Collections .addAll (vertexText , "力量" , "敏捷" , "速度" , "智力" , "精神" , "耐力" , "体力" , "魔力" , "意志" , "幸运" );
3236 mRadarView .setVertexText (vertexText );
37+
3338 List <Integer > res = new ArrayList <>();
34- Collections .addAll (res , R .mipmap .ic_launcher , R .mipmap .ic_launcher , R .mipmap .ic_launcher ,
35- R .mipmap .ic_launcher , R .mipmap .ic_launcher , R .mipmap .ic_launcher ,
36- R .mipmap .ic_launcher , R .mipmap .ic_launcher , R .mipmap .ic_launcher , R .mipmap .ic_launcher );
39+ Collections .addAll (res , R .mipmap .power , R .mipmap .agile , R .mipmap .speed ,
40+ R .mipmap .intelligence , R .mipmap .spirit , R .mipmap .endurance ,
41+ R .mipmap .strength , R .mipmap .magic , R .mipmap .will , R .mipmap .lucky );
3742 mRadarView .setVertexIconResid (res );
43+
3844 List <Float > values = new ArrayList <>();
39- Collections .addAll (values , 3f , 6f , 2f , 7f , 5f , 1f , 4f , 3f , 8f , 5f );
45+ Collections .addAll (values , 3f , 6f , 2f , 7f , 5f , 1f , 9f , 3f , 8f , 5f );
4046 RadarData data = new RadarData (values );
41- data . setValueTextEnable ( true );
42- data . setVauleTextColor ( Color . WHITE );
47+ mRadarView . addData ( data );
48+
4349 List <Float > values2 = new ArrayList <>();
44- Collections .addAll (values2 , 7f , 1f , 4f , 2f , 8f , 3f , 9f , 6f , 5f , 3f );
50+ Collections .addAll (values2 , 7f , 1f , 4f , 2f , 8f , 3f , 4f , 6f , 5f , 3f );
4551 RadarData data2 = new RadarData (values2 );
46- mRadarView .addData (data );
52+ data2 .setValueTextEnable (true );
53+ data2 .setVauleTextColor (Color .WHITE );
54+ data2 .setValueTextSize (dp2px (10 ));
55+ data2 .setLineWidth (dp2px (1 ));
4756 mRadarView .addData (data2 );
4857 }
4958
@@ -80,4 +89,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
8089 }
8190 return super .onOptionsItemSelected (item );
8291 }
92+
93+ private float dp2px (float dpValue ) {
94+ final float scale = getResources ().getDisplayMetrics ().density ;
95+ return dpValue * scale + 0.5f ;
96+ }
8397}
0 commit comments