Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Change InsetDrawable Inset value after creation

I have an InsetDrawable defined, and I would just like to be able to adjust the value of the inset at runtime, without re-assigning another drawable.

Is this possible?, or is the only way is to re-create the InsetDrawable?

like image 205
Johnny Avatar asked Jan 24 '16 14:01

Johnny


1 Answers

It is not possible, because the API for that is not public. I had the same problem as you did, but in my case I had to animate the insets, so recreating the drawable was a quite costly option.

In the end I copied the source code of InsetDrawable, and added a method for changing the inset.

You can check it out here. Use the method setInsets() for changing the insets.

like image 102
Daniel Zolnai Avatar answered Sep 24 '22 01:09

Daniel Zolnai