Merge "Avoid repositioning unattached overlay views" into jb-mr2-dev

This commit is contained in:
Chet Haase
2013-04-16 17:58:36 +00:00
committed by Android (Google) Code Review
2 changed files with 4 additions and 2 deletions

View File

@@ -47,7 +47,8 @@ public class ViewGroupOverlay extends ViewOverlay {
* animation effect.</p>
*
* <p>If the view has a parent, the view will be removed from that parent
* before being added to the overlay. Also, the view will be repositioned
* before being added to the overlay. Also, if that parent is attached
* in the current view hierarchy, the view will be repositioned
* such that it is in the same relative location inside the activity. For
* example, if the view's current parent lies 100 pixels to the right
* and 200 pixels down from the origin of the overlay's

View File

@@ -157,7 +157,8 @@ public class ViewOverlay {
public void add(View child) {
if (child.getParent() instanceof ViewGroup) {
ViewGroup parent = (ViewGroup) child.getParent();
if (parent != mHostView) {
if (parent != mHostView && parent.getParent() != null &&
parent.mAttachInfo != null) {
// Moving to different container; figure out how to position child such that
// it is in the same location on the screen
int[] parentLocation = new int[2];