Android scaledrawable doesn't seems to work

前端 未结 5 1243
旧时难觅i
旧时难觅i 2020-12-09 01:58

I\'m trying out the android ScaleDrawable

But it doesn\'t seem to work... I created the xml as in the documentation example and I have a logo.png in the drawable fol

5条回答
  •  没有蜡笔的小新
    2020-12-09 02:24

    ScaleDrawable not only allows you to scale a drawable, it also allows you to control the scale using setLevel on the ScaleDrawable itself. But the ScaleDrawable doesn't change the intrinsic width and height of the drawable As @m039 pointed out, the ScaleDrawable source actually does a strange thing: when the original drawable's level is set to 0, the scaleDrawable itself won't draw.

    To take effect of the scale, you have to do something like this:

    ScaleDrawable scaleDrawable = (ScaleDrawable) imageView.getDrawable();
    scaleDrawable.setLevel(10000);
    or 
    scaleDrawable.setLevel(5000);
    

提交回复
热议问题