2012-06-09 14 views
5

Il ridimensionamento con ScaleDrawable non funziona per me.
Il drawable è rimasto nella stessa dimensione.Impossibile scalare il disegno con ScaleDrawable

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

Cosa devo fare per risolverlo?
Grazie.

risposta

2

Se si seleziona reference per ScaleDrawable, si vedrà che il metodo getDrawable restituisce il file di base. Cioè, restituisce d nel tuo caso. Dovresti solo restituire sd dato che è già un Drawable.

6

è necessario impostare la 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; 

Il livello varia da 0 a 10000: a 10000 è full size, a 0 non compare affatto.