Android: Is it possible to scale a xml drawable? Android: Is it possible to scale a xml drawable? xml xml

Android: Is it possible to scale a xml drawable?


This is an issue with the ScaleDrawable object which cannot be resolved in XML.

But it is easy, just do the following:

// Get the scale drawable from your resourcesScaleDrawable scaleDraw = (ScaleDrawable)getResources().getDrawable(R.drawable.background_scale);// set the Level to 1 (or anything higher than 0)scaleDraw.setLevel(1);// Now assign the drawable where you need itlayout.setBackgroundDrawable(scaleDraw);

I tested your code using this solution and it worked fine.