From ecc272447c7b492cbe4b0c10ec61b9a6898e6591 Mon Sep 17 00:00:00 2001 From: Sihua Ma Date: Tue, 21 Jun 2022 11:16:21 -0700 Subject: [PATCH] Fill the fade-in ImageView with its content for the cross fade animation The cross fade function of DragView tries to match the shapes of the fade-in and fade-out views. However, ImageView (the fade-in view) by default only tries to match at least one axis between the content (the final view) and the bound (the ImageView bounding box). We need to make sure that the content fully fills the bound to exactly match the shapes. Test: Manual Fix: 221496442 Change-Id: I7c142d52b7bfbd0e266a917c27cbd40691fbf3c2 --- src/com/android/launcher3/dragndrop/DragView.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java index 0264ae21be..09fe740d23 100644 --- a/src/com/android/launcher3/dragndrop/DragView.java +++ b/src/com/android/launcher3/dragndrop/DragView.java @@ -363,7 +363,10 @@ public abstract class DragView extends Fram // If the content is already removed, ignore return; } - View newContent = getViewFromDrawable(getContext(), crossFadeDrawable); + ImageView newContent = getViewFromDrawable(getContext(), crossFadeDrawable); + // We need to fill the ImageView with the content, otherwise the shapes of the final view + // and the drag view might not match exactly + newContent.setScaleType(ImageView.ScaleType.FIT_XY); newContent.measure(makeMeasureSpec(mWidth, EXACTLY), makeMeasureSpec(mHeight, EXACTLY)); newContent.layout(0, 0, mWidth, mHeight); addViewInLayout(newContent, 0, new LayoutParams(mWidth, mHeight)); @@ -573,7 +576,7 @@ public abstract class DragView extends Fram } } - private static View getViewFromDrawable(Context context, Drawable drawable) { + private static ImageView getViewFromDrawable(Context context, Drawable drawable) { ImageView iv = new ImageView(context); iv.setImageDrawable(drawable); return iv;