diff --git a/api/current.txt b/api/current.txt index 015c03509b907..792e4e7b1032b 100644 --- a/api/current.txt +++ b/api/current.txt @@ -944,6 +944,8 @@ package android { field public static final int popupBackground = 16843126; // 0x1010176 field public static final int popupCharacters = 16843332; // 0x1010244 field public static final int popupElevation = 16843916; // 0x101048c + field public static final int popupEnterTransition = 16844065; // 0x1010521 + field public static final int popupExitTransition = 16844066; // 0x1010522 field public static final int popupKeyboard = 16843331; // 0x1010243 field public static final int popupLayout = 16843323; // 0x101023b field public static final int popupMenuStyle = 16843520; // 0x1010300 @@ -47203,6 +47205,8 @@ package android.widget { method public android.graphics.drawable.Drawable getBackground(); method public android.view.View getContentView(); method public float getElevation(); + method public android.transition.Transition getEnterTransition(); + method public android.transition.Transition getExitTransition(); method public int getHeight(); method public int getInputMethodMode(); method public int getMaxAvailableHeight(android.view.View); diff --git a/api/system-current.txt b/api/system-current.txt index 741290848fafb..f5171da8b86d0 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -1039,6 +1039,8 @@ package android { field public static final int popupBackground = 16843126; // 0x1010176 field public static final int popupCharacters = 16843332; // 0x1010244 field public static final int popupElevation = 16843916; // 0x101048c + field public static final int popupEnterTransition = 16844065; // 0x1010521 + field public static final int popupExitTransition = 16844066; // 0x1010522 field public static final int popupKeyboard = 16843331; // 0x1010243 field public static final int popupLayout = 16843323; // 0x101023b field public static final int popupMenuStyle = 16843520; // 0x1010300 @@ -50301,6 +50303,8 @@ package android.widget { method public android.graphics.drawable.Drawable getBackground(); method public android.view.View getContentView(); method public float getElevation(); + method public android.transition.Transition getEnterTransition(); + method public android.transition.Transition getExitTransition(); method public int getHeight(); method public int getInputMethodMode(); method public int getMaxAvailableHeight(android.view.View); diff --git a/api/test-current.txt b/api/test-current.txt index 34c14d4e54f56..80851e6950c7b 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -944,6 +944,8 @@ package android { field public static final int popupBackground = 16843126; // 0x1010176 field public static final int popupCharacters = 16843332; // 0x1010244 field public static final int popupElevation = 16843916; // 0x101048c + field public static final int popupEnterTransition = 16844065; // 0x1010521 + field public static final int popupExitTransition = 16844066; // 0x1010522 field public static final int popupKeyboard = 16843331; // 0x1010243 field public static final int popupLayout = 16843323; // 0x101023b field public static final int popupMenuStyle = 16843520; // 0x1010300 @@ -47276,6 +47278,8 @@ package android.widget { method public android.graphics.drawable.Drawable getBackground(); method public android.view.View getContentView(); method public float getElevation(); + method public android.transition.Transition getEnterTransition(); + method public android.transition.Transition getExitTransition(); method public int getHeight(); method public int getInputMethodMode(); method public int getMaxAvailableHeight(android.view.View); diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java index dd6a41f9d209c..a1417f0cbb68c 100644 --- a/core/java/android/widget/PopupWindow.java +++ b/core/java/android/widget/PopupWindow.java @@ -16,12 +16,10 @@ package android.widget; -import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME; -import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH; - import com.android.internal.R; import android.annotation.NonNull; +import android.annotation.Nullable; import android.content.Context; import android.content.res.TypedArray; import android.graphics.PixelFormat; @@ -54,10 +52,46 @@ import android.view.WindowManager.LayoutParams; import java.lang.ref.WeakReference; +import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME; +import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH; + /** - *
A popup window that can be used to display an arbitrary view. The popup - * window is a floating container that appears on top of the current - * activity.
+ *+ * This class represents a popup window that can be used to display an + * arbitrary view. The popup window is a floating container that appears on top + * of the current activity. + *
+ * + *+ * On all versions of Android, popup window enter and exit animations may be + * specified by calling {@link #setAnimationStyle(int)} and passing the + * resource ID for an animation style that defines {@code windowEnterAnimation} + * and {@code windowExitAnimation}. For example, passing + * {@link android.R.style#Animation_Dialog} will give a scale and alpha + * animation. + * + * A window animation style may also be specified in the popup window's style + * XML via the {@link android.R.styleable#PopupWindow_popupAnimationStyle popupAnimationStyle} + * attribute. + *
+ *+ * Starting with API 23, more complex popup window enter and exit transitions + * may be specified by calling either {@link #setEnterTransition(Transition)} + * or {@link #setExitTransition(Transition)} and passing a {@link Transition}. + * + * Popup enter and exit transitions may also be specified in the popup window's + * style XML via the {@link android.R.styleable#PopupWindow_popupEnterTransition popupEnterTransition} + * and {@link android.R.styleable#PopupWindow_popupExitTransition popupExitTransition} + * attributes, respectively. + *
+ * + * @attr ref android.R.styleable#PopupWindow_overlapAnchor + * @attr ref android.R.styleable#PopupWindow_popupAnimationStyle + * @attr ref android.R.styleable#PopupWindow_popupBackground + * @attr ref android.R.styleable#PopupWindow_popupElevation + * @attr ref android.R.styleable#PopupWindow_popupEnterTransition + * @attr ref android.R.styleable#PopupWindow_popupExitTransition * * @see android.widget.AutoCompleteTextView * @see android.widget.Spinner @@ -351,14 +385,53 @@ public class PopupWindow { setFocusable(focusable); } - public void setEnterTransition(Transition enterTransition) { + /** + * Sets the enter transition to be used when the popup window is shown. + * + * @param enterTransition the enter transition, or {@code null} to clear + * @see #getEnterTransition() + * @attr ref android.R.styleable#PopupWindow_popupEnterTransition + */ + public void setEnterTransition(@Nullable Transition enterTransition) { mEnterTransition = enterTransition; } - public void setExitTransition(Transition exitTransition) { + /** + * Returns the enter transition to be used when the popup window is shown. + * + * @return the enter transition, or {@code null} if not set + * @see #setEnterTransition(Transition) + * @attr ref android.R.styleable#PopupWindow_popupEnterTransition + */ + @Nullable + public Transition getEnterTransition() { + return mEnterTransition; + } + + /** + * Sets the exit transition to be used when the popup window is dismissed. + * + * @param exitTransition the exit transition, or {@code null} to clear + * @see #getExitTransition() + * @attr ref android.R.styleable#PopupWindow_popupExitTransition + */ + public void setExitTransition(@Nullable Transition exitTransition) { mExitTransition = exitTransition; } + /** + * Returns the exit transition to be used when the popup window is + * dismissed. + * + * @return the exit transition, or {@code null} if not set + * @see #setExitTransition(Transition) + * @attr ref android.R.styleable#PopupWindow_popupExitTransition + */ + @Nullable + public Transition getExitTransition() { + return mExitTransition; + } + /** * Sets the bounds used as the epicenter of the enter and exit transitions. *
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 4e8740a52fb50..1c91342af286a 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2707,6 +2707,8 @@