I have this code to cross out the ImageView background:
private void setWithCrossfade(Bitmap bitmap) {
Drawable backgrounds[] = new Drawable[2];
backgrounds[0] = mImageView.getDrawable();
backgrounds[1] = new BitmapDrawable(mImageView.getResources(), bitmap);
TransitionDrawable transitionDrawable = new TransitionDrawable(backgrounds);
transitionDrawable.setCrossFadeEnabled(true);
mImageView.setAdjustViewBounds(false);
mImageView.setImageDrawable(transitionDrawable);
mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
transitionDrawable.startTransition(250);
}
ImageView is scaleTypeset to centerCropin XML layout. However, when the crossfade ends, the new bitmap is set to fitXY. In another thread, they say that this can be solved by dropping scaleType, but it does not work. Resizing a bitmap image is not a good solution in terms of memory. Is there any way around this? Thank you very much.
PS: Please do not offer crossfading 2 ImageViews or thanks to ViewSwitcher.
source
share