How to change chart background with MPAndroidChart library?

后端 未结 4 616
一个人的身影
一个人的身影 2021-01-18 01:28

I\'m using the amazing library MPAndroidChart. It works like a charm, except when I\'m trying to change the background color of the BarData. Default color is white, and I wa

相关标签:
4条回答
  • 2021-01-18 01:31

    Code to change Background color:

    chart.setBackgroundColor(Color.TRANSPARENT); //set whatever color you prefer
    chart.setDrawGridBackground(false);// this is a must 
    
    0 讨论(0)
  • 2021-01-18 01:37

    So, after some research, I've found that it's not possible yet: https://github.com/PhilJay/MPAndroidChart/issues/53

    Hope It will be possible soon ! =)

    0 讨论(0)
  • 2021-01-18 01:38

    Since release v1.6.5, the background of the Chart is transparent by default. Meaning, that everything in the background (chart background, other Views, etc.) that is not overlayed by data drawn into the Chart, will be visible.

    If you want to change the background (color, or maybe drawable), you can either do that by changing the chart-background

    • in .xml (android:background="...")
    • by calling setBackgroundColor(...) or setBackgroundResource(...)

    Another way could be to change the background of the parent layout that contains the Chart.

    0 讨论(0)
  • 2021-01-18 01:51

    if you want to Change Whole Screen Background Color

     Barchart chart;
     chart.setBackgroundColor(Color.rgb(0, 0, 0));//Set as a black
     chart.setDrawGridBackground(false);//set this to true to draw the grid background, false if not
    

    Happy to help Thanks

    0 讨论(0)
提交回复
热议问题