1/* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.support.transition; 18 19import android.content.Context; 20import android.graphics.drawable.Drawable; 21import android.view.View; 22import android.view.ViewGroup; 23 24class ViewGroupOverlay extends ViewOverlay { 25 26 ViewGroupOverlay(Context context, ViewGroup hostView, View requestingView) { 27 super(context, hostView, requestingView); 28 } 29 30 public static ViewGroupOverlay createFrom(ViewGroup viewGroup) { 31 return (ViewGroupOverlay) ViewOverlay.createFrom(viewGroup); 32 } 33 34 /** 35 * Adds a View to the overlay. The bounds of the added view should be 36 * relative to the host view. Any view added to the overlay should be 37 * removed when it is no longer needed or no longer visible. 38 * 39 * <p>Views in the overlay are visual-only; they do not receive input 40 * events and do not participate in focus traversal. Overlay views 41 * are intended to be transient, such as might be needed by a temporary 42 * animation effect.</p> 43 * 44 * <p>If the view has a parent, the view will be removed from that parent 45 * before being added to the overlay. Also, if that parent is attached 46 * in the current view hierarchy, the view will be repositioned 47 * such that it is in the same relative location inside the activity. For 48 * example, if the view's current parent lies 100 pixels to the right 49 * and 200 pixels down from the origin of the overlay's 50 * host view, then the view will be offset by (100, 200).</p> 51 * 52 * @param view The View to be added to the overlay. The added view will be 53 * drawn when the overlay is drawn. 54 * @see #remove(View) 55 * @see android.view.ViewOverlay#add(Drawable) 56 */ 57 public void add(View view) { 58 mOverlayViewGroup.add(view); 59 } 60 61 /** 62 * Removes the specified View from the overlay. 63 * 64 * @param view The View to be removed from the overlay. 65 * @see #add(View) 66 * @see android.view.ViewOverlay#remove(Drawable) 67 */ 68 public void remove(View view) { 69 mOverlayViewGroup.remove(view); 70 } 71} 72