int values.
+ * This evaluator can be used to perform type interpolation between Rect values.
*/
public class RectEvaluator implements TypeEvaluatorViewGroupOverlay is a subclass of {@link ViewOverlay}, adding the ability to + * manage views for overlays on ViewGroups, in addition to the drawable + * support in ViewOverlay.
+ * + * @see ViewGroup#getOverlay() */ -public interface Overlay { +public class ViewGroupOverlay extends ViewOverlay { - /** - * Adds a Drawable to the overlay. The bounds of the drawable should be relative to - * the host view. Any drawable added to the overlay should be removed when it is no longer - * needed or no longer visible. - * - * @param drawable The Drawable to be added to the overlay. This drawable will be - * drawn when the view redraws its overlay. - * @see #remove(android.graphics.drawable.Drawable) - * @see #add(View) - */ - void add(Drawable drawable); - - /** - * Removes the specified Drawable from the overlay. - * - * @param drawable The Drawable to be removed from the overlay. - * @see #add(android.graphics.drawable.Drawable) - */ - void remove(Drawable drawable); + ViewGroupOverlay(Context context, View hostView) { + super(context, hostView); + } /** * Adds a View to the overlay. The bounds of the added view should be * relative to the host view. Any view added to the overlay should be * removed when it is no longer needed or no longer visible. * + *Views in the overlay are visual-only; they do not receive input + * events and do not participate in focus traversal. Overlay views + * are intended to be transient, such as might be needed by a temporary + * animation effect.
+ * *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 * such that it is in the same relative location inside the activity. For @@ -62,20 +56,20 @@ public interface Overlay { * @param view The View to be added to the overlay. The added view will be * drawn when the overlay is drawn. * @see #remove(View) - * @see #add(android.graphics.drawable.Drawable) + * @see ViewOverlay#add(Drawable) */ - void add(View view); + public void add(View view) { + mOverlayViewGroup.add(view); + } /** * Removes the specified View from the overlay. * * @param view The View to be removed from the overlay. * @see #add(View) + * @see ViewOverlay#remove(Drawable) */ - void remove(View view); - - /** - * Removes all views and drawables from the overlay. - */ - void clear(); + public void remove(View view) { + mOverlayViewGroup.remove(view); + } } diff --git a/core/java/android/view/ViewOverlay.java b/core/java/android/view/ViewOverlay.java index 8b18d53b7ee19..78e2597d728c0 100644 --- a/core/java/android/view/ViewOverlay.java +++ b/core/java/android/view/ViewOverlay.java @@ -23,215 +23,286 @@ import android.graphics.drawable.Drawable; import java.util.ArrayList; /** - * ViewOverlay is a container that View uses to host all objects (views and - * drawables) that are added to its "overlay", gotten through - * {@link View#getOverlay()}. Views and drawables are added to the overlay - * via the add/remove methods in this class. These views and drawables are - * drawn whenever the view itself is drawn; first the view draws its own - * content (and children, if it is a ViewGroup), then it draws its overlay - * (if it has one). + * An overlay is an extra layer that sits on top of a View (the "host view") + * which is drawn after all other content in that view (including children, + * if the view is a ViewGroup). Interaction with the overlay layer is done + * by adding and removing drawables. * - * Besides managing and drawing the list of drawables, this class serves - * two purposes: - * (1) it noops layout calls because children are absolutely positioned and - * (2) it forwards all invalidation calls to its host view. The invalidation - * redirect is necessary because the overlay is not a child of the host view - * and invalidation cannot therefore follow the normal path up through the - * parent hierarchy. + *
An overlay requested from a ViewGroup is of type {@link ViewGroupOverlay}, + * which also supports adding and removing views.
* - * @hide + * @see View#getOverlay() View.getOverlay() + * @see ViewGroup#getOverlay() ViewGroup.getOverlay() + * @see ViewGroupOverlay */ -class ViewOverlay extends ViewGroup implements Overlay { +public class ViewOverlay { /** - * The View for which this is an overlay. Invalidations of the overlay are redirected to - * this host view. + * The actual container for the drawables (and views, if it's a ViewGroupOverlay). + * All of the management and rendering details for the overlay are handled in + * OverlayViewGroup. */ - View mHostView; + OverlayViewGroup mOverlayViewGroup; - /** - * The set of drawables to draw when the overlay is rendered. - */ - ArrayListBesides managing and drawing the list of drawables, this class serves + * two purposes: + * (1) it noops layout calls because children are absolutely positioned and + * (2) it forwards all invalidation calls to its host view. The invalidation + * redirect is necessary because the overlay is not a child of the host view + * and invalidation cannot therefore follow the normal path up through the + * parent hierarchy.
+ * + * @see View#getOverlay() + * @see ViewGroup#getOverlay() */ + static class OverlayViewGroup extends ViewGroup { - @Override - public void invalidate(Rect dirty) { - super.invalidate(dirty); - if (mHostView != null) { - mHostView.invalidate(dirty); + /** + * The View for which this is an overlay. Invalidations of the overlay are redirected to + * this host view. + */ + View mHostView; + + /** + * The set of drawables to draw when the overlay is rendered. + */ + ArrayList