summaryrefslogtreecommitdiff
path: root/core/java/android/view/ViewGroupOverlay.java
diff options
context:
space:
mode:
authorChet Haase <chet@google.com>2013-04-15 15:15:59 -0700
committerChet Haase <chet@google.com>2013-04-15 15:15:59 -0700
commitface742d31a7a72a4bdced5594e00e51ecee6c84 (patch)
tree3f8d288fd0514f275d3f173108a0adbc56786990 /core/java/android/view/ViewGroupOverlay.java
parent30c990c361291ad578ef4ffe4a4dd0fd6080797b (diff)
Avoid repositioning unattached overlay views
Adding a view to an overlay usually entails removing the view from its current parent, if it has one. ViewOverlay.add() will do this automatically. At the same time, it will check to see whether the parent view is in a different global location than the overlay's host view, and will adjust the added view accordingly. This enables the caller to simply toss a view into an overlay and have it end up at the same global position on the screen. the problem is that the current code doesn't bother to check whether the old parent is attached. If that parent has been removed from the view hierarchy before this overlay operation, then it will show up as being at (0,0) in the window, not its old location. This results in the view being mis-positioned in the overaly. Fix is simple: if the view's old parent is not attached, simply remove it from that parent before adding it to the overlay; don't try to compensate for its position which is based on wrong information. Issue #8620319 Overlay should only use relative window locations for onscreen parents Change-Id: I414038a6c355dfd58f9766b007ac44d535ef1889
Diffstat (limited to 'core/java/android/view/ViewGroupOverlay.java')
-rw-r--r--core/java/android/view/ViewGroupOverlay.java3
1 files changed, 2 insertions, 1 deletions
diff --git a/core/java/android/view/ViewGroupOverlay.java b/core/java/android/view/ViewGroupOverlay.java
index c1b24f26503c..16afc5df31ae 100644
--- a/core/java/android/view/ViewGroupOverlay.java
+++ b/core/java/android/view/ViewGroupOverlay.java
@@ -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