我想製作一個涵蓋整個父級佈局但不是它的水平條形圖。以下是我的代碼 -如何從mpandroidchart的水平條形圖中移除填充?
HorizontalBarChart barchart = new HorizontalBarChart(activity);
barchart.setLayoutParams(new LinearLayout.LayoutParams(0, 110, weight));
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
entries.add(new BarEntry(86.0f, 0));
BarDataSet dataset = new BarDataSet(entries, "");
dataset.setColor(Color.parseColor("#E0E0E0"));
ArrayList<String> labels = new ArrayList<String>();
labels.add("86.0");
BarData bardata = new BarData(labels, dataset);
barchart.setData(bardata);
barchart.setDescription("");
Legend legend = barchart.getLegend();
legend.setEnabled(false);
YAxis topAxis = barchart.getAxisLeft();
topAxis.setDrawLabels(false);
YAxis bottomAxis = barchart.getAxisRight();
bottomAxis.setDrawLabels(false);
XAxis rightAxis = barchart.getXAxis();
rightAxis.setDrawLabels(false);
bottomAxis.setDrawLabels(false);
barchart.setPadding(-1, -1, -1, -1);
barchart.setBackgroundColor(Color.CYAN);
return barchart;
我想讓我的水平條形圖(條形圖)填滿整個藍色區域。有人可以請幫助。
編輯:@PhilippJahoda我試過你的解決方案,但在第一次啓動時,它顯示的方式與之前一樣,當我點擊/觸摸圖表時只會覆蓋整個區域。你能告訴我爲什麼我必須觸摸圖表才能填滿整個空間。
在首次啓動時,它看起來像 -
屏幕截圖:它看起來
點擊後像 -
屏幕SHOT2:
請看到我的編輯 – Agr1909
請看到我的編輯 – Agr1909
它這是我遇到的同樣的問題。我在設置圖表數據後調用chart.setViewPortOffset(100f,0f,100f,0f)..但是隻有在點擊圖表後我的編輯纔會生效。任何解決方案@PhilippJahoda?我有最新的mpchart lib版本。 –