From 4497ebf9a2726e2a7dbb7f3c49389308908f8454 Mon Sep 17 00:00:00 2001 From: Andrew Flynn Date: Wed, 9 May 2012 11:28:00 -0700 Subject: Fix drag layer Change-Id: Iac2f53cdd765df9097a5a5a75b37cdacb03fb633 --- src/com/android/launcher2/DragLayer.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java index b31666571..4be1914e0 100644 --- a/src/com/android/launcher2/DragLayer.java +++ b/src/com/android/launcher2/DragLayer.java @@ -462,7 +462,16 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang float scale = getDescendantCoordRelativeToSelf((View) child.getParent(), coord); int toX = coord[0]; int toY = coord[1]; - if (child instanceof FolderIcon) { + if (child instanceof TextView) { + TextView tv = (TextView) child; + + // The child may be scaled (always about the center of the view) so to account for it, + // we have to offset the position by the scaled size. Once we do that, we can center + // the drag view about the scaled child view. + toY += Math.round(scale * tv.getPaddingTop()); + toY -= dragView.getMeasuredHeight() * (1 - scale) / 2; + toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2; + } else if (child instanceof FolderIcon) { // Account for holographic blur padding on the drag view toY -= Workspace.DRAG_BITMAP_PADDING / 2; // Center in the x coordinate about the target's drawable -- cgit v1.2.3