CircleImageView---------------------------------------------------------------------------
1.升级supportv4 最新jar包:http://download.youkuaiyun.com/detail/a704755096/9384965,使用RoundedBitmapDrawable,RoundedBitmapDrawable 是 android.support.v4.graphics.drawable 里面的一个类,用来创建简单的圆角图片。 如果只是简单的圆角展示,比如展示一个圆角头像,这个类完全可以胜任(支持正方形的原始图片,不要设置android:scaleType="fitXY")。
ImageView image = (ImageView) findViewById(R.id.imageView1);
RoundedBitmapDrawable rbm = RoundedBitmapDrawableFactory.create(getResources(), BitmapFactory.decodeResource(getResources(), R.drawable.logo));
rbm.setCornerRadius(10);//设置圆角
rbm.setAntiAlias(true);
image.setImageDrawable(rbm);
2.开源库 github地址: https://github.com/hdodenhof/CircleImageView
A fast circular ImageView perfect for profile images. This is based on RoundedImageView from Vince Mi which itself is based on techniques recommended by Romain Guy.
<com.github.mikephil.charting.charts.BarChart
android:id="@+id/chart1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
private void initBarChart() {
BarChart mChart = (BarChart) findViewById(R.id.chart1);
// mChart.setOnChartValueSelectedListener(this);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
// mChart.setDrawYLabels(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);//x轴数据位置
xAxis.setDrawGridLines(false);
xAxis.setSpaceBetweenLabels(1);
YAxisValueFormatter custom = new com.wlhl.hong.MyYAxisValueFormatter();
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setLabelCount(8, false);
leftAxis.setValueFormatter(custom);
leftAxis.setPosition(YAxisLabelPosition.OUTSIDE_CHART);
leftAxis.setSpaceTop(15f);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setLabelCount(8, false);
rightAxis.setValueFormatter(custom);
rightAxis.setSpaceTop(15f);
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.ABOVE_CHART_LEFT);
l.setForm(LegendForm.SQUARE);
l.setFormSize(0f);
l.setTextSize(14f);
l.setXEntrySpace(4f);
mChart.setDragEnabled(true);//拖拽 drag
mChart.setScaleEnabled(true);//缩放scale
mChart.animateX(1000); //动画animation x
setData(12, 60);
}
private void setData(int count, float range) {
ArrayList<String> xVals = new ArrayList<String>();//x轴数据
for (int i = 0; i < count; i++) {
xVals.add(i+"");
}
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();//y轴数据
for (int i = 0; i < count; i++) {
float mult = (range + 1);
float val = (float) (Math.random() * mult);
yVals1.add(new BarEntry(val, i));
}
BarDataSet set1 = new BarDataSet(yVals1, "提示数据");
set1.setBarSpacePercent(35f);
set1.setColor(getResources().getColor(R.color.light_blue));//柱状图颜色bar color
ArrayList<BarDataSet> dataSets = new ArrayList<BarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10f);
mChart.setData(data);
}
<com.github.mikephil.charting.charts.LineChart
android:id="@+id/chart1"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
private void initLineChart() {
LineChart mChart = (LineChart) findViewById(R.id.chart1);
// mChart.setOnChartValueSelectedListener(this);
mChart.setDrawGridBackground(false);
mChart.setDescription("");
mChart.setDrawBorders(false);
mChart.getAxisLeft().setDrawAxisLine(true);
mChart.getAxisLeft().setDrawGridLines(true);
mChart.getAxisRight().setDrawAxisLine(true);
mChart.getAxisRight().setDrawGridLines(true);
mChart.getXAxis().setDrawAxisLine(false);
mChart.getXAxis().setDrawGridLines(false);
mChart.getXAxis().setPosition(XAxisPosition.BOTTOM);
// enable touch gestures
mChart.setTouchEnabled(true);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(false);
Legend l = mChart.getLegend();
l.setForm(LegendForm.CIRCLE);
l.setPosition(LegendPosition.BELOW_CHART_CENTER);
ArrayList<String> xVals = new ArrayList<String>();//x轴数据
for (int i = 0; i <10; i++) {
xVals.add((i) + "");
}
ArrayList<LineDataSet> dataSets = new ArrayList<LineDataSet>();
for (int z = 0; z < 4; z++) {
ArrayList<Entry> values = new ArrayList<Entry>();//x轴和y轴交点数据
for (int i = 0; i < 10; i++) {
double val = Math.random() *10;
values.add(new Entry((float) val, i));
}
LineDataSet d = new LineDataSet(values,classify[z]);//自定义图表提示
d.setLineWidth(2.5f);
d.setCircleSize(4f);
int color = mColors[z % mColors.length];
d.setColor(color);
d.setCircleColor(color);
dataSets.add(d);
}
// make the first DataSet dashed
// dataSets.get(0).enableDashedLine(10, 10, 0);
// dataSets.get(0).setColors(ColorTemplate.VORDIPLOM_COLORS);
// dataSets.get(0).setCircleColors(ColorTemplate.VORDIPLOM_COLORS);
LineData data = new LineData(xVals, dataSets);
mChart.animateX(1000);
mChart.setData(data);
}