KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I need to paint the background of my Canvas one color with shading/gradient applied, but each onDraw call I would like to potentially change the color. I am having trouble doing this without creating a new object each onDraw call. Anyone have any ideas? If I use drawPaint() and set a new shader() to my paint, then I have created a new shader object and if I create a new GradientDrawable() I have as well. I want to avoid GC. I thought I could reuse one GradientDrawable() object and call the .setColor() method, but this just resets any gradient data associated it and paints the drawable as that solid color. Anyone?
Tags (comma-separated)
Save Edits
Cancel