ananda perera
ananda perera

Reputation: 1

How to add background image behind the graph in android GraphView

I am developing an Android app which plot point graph (scatter plot) using android GraphView library. I need to put a background image behind my graph. I tried,

int imageResource = getResources().getIdentifier("@drawable/cyan", null, getPackageName());
myplot.setBackgroundResource(imageResource);

("cyan" is the name of the image (.jpg format) and it is in drawable folder). But nothing happens. Can anyone make some suggestion?

Upvotes: 0

Views: 263

Answers (1)

Amiraslan
Amiraslan

Reputation: 812

Did you try this:

Drawable image = ContextCompat.getDrawable(this, R.drawable.cyan);
myplot.setBackground(image);

Upvotes: 1

Related Questions