Merge "Fix drag layer" into jb-dev

This commit is contained in:
Andrew Flynn
2012-05-09 13:35:33 -07:00
committed by Android (Google) Code Review
+10 -1
View File
@@ -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