I am trying to scale a drawable but failing. However that is not the question in this case, it does however seem to have something to do with the setLevel() method.
Im having an extremely hard time trying to figure out what this does and when I am supposed to use it, from the documentation it states:
Specify the level for the drawable. This allows a drawable to vary its imagery based on a continuous controller, for example to show progress or volume level.
If the new level you are supplying causes the appearance of the Drawable to change, then it is responsible for calling invalidateSelf() in order to have itself redrawn, and true will be returned from this function.
Parameters level The new level, from 0 (minimum) to 10000 (maximum). Returns Returns true if this change in level has caused the appearance of the Drawable to change (hence requiring an invalidate), otherwise returns false.
What is the controller for example? When and how is this to be used?
A Drawable's level is, basically, an integer number. It has different meanings for different kinds of Drawable
subclasses. For example:
GradientDrawable
, it specifies what fraction of the gradient should be drawn.RotateDrawable
, it specifies the rotation angle.ScaleDrawable
, it changes size of another Drawable
, so ScaleDrawable
is like a wrapper around another Drawable
and crops it based on current level.The controller, for example, can be a ProgressBar
. This is precisely how determinate progress bars are drawn. You can check this question for more details
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With