我正在尝试向活动添加一个静态条形图,但它覆盖了整个屏幕。我正在使用的代码如下 -
MainActivity.java
BarChart bc = (BarChart) findViewById(R.id.chart);
ArrayList<BarEntry> entries = new ArrayList<>();
entries.add(new BarEntry(4f, 0));
entries.add(new BarEntry(8f, 1));
entries.add(new BarEntry(6f, 2));
entries.add(new BarEntry(12f, 3));
entries.add(new BarEntry(18f, 4));
entries.add(new BarEntry(9f, 5));
entries.add(new BarEntry(12f, 6));
entries.add(new BarEntry(10f, 7));
BarDataSet dataset = new BarDataSet(entries, "# of Calls");
ArrayList<String> labels = new ArrayList<String>();
labels.add("January");
labels.add("February");
labels.add("March");
labels.add("April");
labels.add("May");
labels.add("June");
labels.add("July");
labels.add("August");
bc=new BarChart(this);
BarData data = new BarData(labels, dataset);
setContentView(bc);
bc.setData(data);
MainActivity.xml
<com.github.mikephil.charting.charts.BarChart
android:layout_width="200dp"
android:layout_height="200dp"
android:id="@+id/chart"
android:layout_below="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="62dp">
</com.github.mikephil.charting.charts.BarChart>
我哪里错了?有什么建议么