Fixing 1-point jump upon switching from DragView to drag shadow.

Upon the end if the growth animation for DragView, we hide DragView and
show the framework DND drag shadow. Rounding problems caused shifting of the
drag image by 1 pixel when the transition happened.

Bug: 22028725
Change-Id: I2a2275a6d18c1a10ceecaecf8a279c6d11d8c7d8
This commit is contained in:
Vadim Tryshev
2015-08-07 15:09:39 -07:00
parent d07b5cd098
commit 9430ff23c8
+5 -3
View File
@@ -199,9 +199,11 @@ public class DragView extends View {
public void provideDragShadowMetrics(Point size, Point touch) {
size.set((int)(mBitmap.getWidth() * getScaleX()), (int)(mBitmap.getHeight() * getScaleY()));
final int xGrowth = (int)(mBitmap.getWidth() * (getScaleX() - mInitialScale));
final int yGrowth = (int)(mBitmap.getHeight() * (getScaleY() - mInitialScale));
touch.set(mRegistrationX + xGrowth / 2, mRegistrationY + yGrowth / 2);
final float xGrowth = mBitmap.getWidth() * (getScaleX() - mInitialScale);
final float yGrowth = mBitmap.getHeight() * (getScaleY() - mInitialScale);
touch.set(
mRegistrationX + (int)Math.round(xGrowth / 2),
mRegistrationY + (int)Math.round(yGrowth / 2));
}
@Override