Unable to scale Drawable with ScaleDrawable

Scaling with ScaleDrawable doesn't work for me.
Allocated remains in the same size.

LayerDrawable layerDrawable = new LayerDrawable(layers); Drawable d = layerDrawable.getCurrent(); ScaleDrawable sd = new ScaleDrawable(d, 0, 0.01f, 0.01f); return sd.getDrawable(); 

What do I need to do to fix this?
Thank.

+5
java android drawable
Jun 09 '12 at 11:01
source share
2 answers

You need to set level :

 LayerDrawable layerDrawable = new LayerDrawable(layers); Drawable d = layerDrawable.getCurrent(); ScaleDrawable sd = new ScaleDrawable(d, 0, 0.01f, 0.01f); sd.setLevel(8000); return sd; 

The level is in the range from 0 to 10000: at 10000 it is the full size, at 0 it is not displayed at all.

+6
Sep 11
source share

If you check the reference for ScaleDrawable , you will see that the getDrawable method returns the base drawing. That is, it returns d in your case. You should just return sd since it is already Drawable .

+2
Jun 09 2018-12-12T00:
source share



All Articles