Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid TransitionDrawable: image scaletype changes upon fragment resuming
    primarykey
    data
    text
    <p>I have an ImageView set as the background for a fragment (the imageview is set to match_parent on both width and height) and the scaletype is set to centerCrop. I download an image to put in there asynchronously and use a TransitionDrawable to crossfade between once it has finished downloading.</p> <p>The image appears with the correct scaletype the first time, however if I navigate to another fragment then back to this fragment with the imageview as the background, the image appears warped/stretched (it looks like the imageView is set to fitXY instead)</p> <p>If I don't use a TransitionDrawable the images stay as they should look.</p> <p>Is there a TransitionDrawable equivalent that maintains the correct aspect ratio? Or is there something I need to set on TransitionDrawable to prevent this resizing?</p> <p>All I really want to do is have a nice transition between images. I was thinking of just setting the image to the second layer drawable of the TransitionDrawable once it has finished animating but there is no way to monitor when the animation has finished...</p> <p>edit: I thought I'd mention the images are not the same dimensions, not sure if that makes a difference</p> <p>Edit 2: Here is the code to set the drawable:</p> <pre><code> //code above to download image BitmapDrawable bitmapDrawable = new BitmapDrawable(imageview.getResources(), bitmap); TransitionDrawable transitionDrawable = new TransitionDrawable(new Drawable[]{imageview.getDrawable(), bitmapDrawable}); imageview.setImageDrawable(transitionDrawable); transitionDrawable.startTransition(300); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload