Unable to scale Drawable with ScaleDrawable

荒凉一梦 提交于 2019-12-04 07:23:25

You need to set the 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 ranges from 0 to 10000: at 10000 it is full size, at 0 it does not appear at all.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!