Skip to content

Commit 79de48e

Browse files
author
rorbin
committed
1、修复在ScrollView等可滑动的ViewGroup中无法触发手势旋转的问题
2、新增LayerLineColor、LayerLineWidth、VertexLineColor、VertexLineWidth属性,可单独设置雷达图顶点连线和各层连线的颜色与宽度,弃用RadarLineEnable、RadarLineWidth、RadarLineColor 3、RadarData新增setLineWidth用来设置数据区多边形外框线宽度
1 parent 88e7db9 commit 79de48e

File tree

16 files changed

+167
-62
lines changed

16 files changed

+167
-62
lines changed

RadarViewDemo/src/main/java/rorbin/q/radarviewdemo/MainActivity.java

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

RadarViewDemo/src/main/res/layout/activity_main.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@
1414
<rorbin.q.radarview.RadarView
1515
android:id="@+id/radarView"
1616
android:layout_width="match_parent"
17-
app:vertex_icon_size="30dp"
18-
app:vertex_text_offset="30dp"
17+
android:layout_height="match_parent"
18+
app:vertex_icon_margin="10dp"
1919
app:vertex_icon_position="top"
20-
android:layout_height="match_parent"/>
20+
app:vertex_icon_size="30dp"
21+
app:vertex_line_color="#99FFFFFF"
22+
app:layer_line_color="#99FFFFFF"
23+
app:vertex_text_color="#FFFFFF"
24+
app:vertex_text_offset="30dp" />
2125
</RelativeLayout>
4.64 KB
Loading
4.9 KB
Loading
2.74 KB
Loading
4.61 KB
Loading
6.68 KB
Loading
5.65 KB
Loading
5.43 KB
Loading
4.74 KB
Loading

0 commit comments

Comments
 (0)