Skip to content Skip to sidebar Skip to footer

Mpandroidchart White Background

I am using the MPAndroidChart library. I am setting the multi line chart with data using MPAndroidChart. It's working great but the background is coming white. This is what i am do

Solution 1:

You want this for transparent:

chart.setDrawGridBackground(false);

And this for transparent bar:

chart.setDrawBarShadow(false);

Solution 2:

Well by default, the backgroud of the chart is transparent which means that it will have whatever color you set for the view/layout below the chart.

If you want to change the background (color, or maybe drawable), you can do that in the following ways:

  • in .xml (android:background="...") --> set the background color of the chart in xml or set the backgroud color of the layout the chart is in.
  • by calling setBackgroundColor(...) or setBackgroundResource(...)

I guess you want your background to be some kind of black? What happens if you call:

chart.setBackgroundColor(Color.BLACK)?

Does setting the background-color work then? Also check the example code in the github repo here. There are some cases in the example app that change the background color.

Solution 3:

You can do this with:

chart.setBackgroundColor(getResources().getColor(R.color.transparent));

Please define first:

<colorname="transparent">#00000000</color>

Post a Comment for "Mpandroidchart White Background"