consp1racy / android-support-preference

Android Preferences according to Material design specs
Apache License 2.0
331 stars 49 forks source link

Simple menu is not animated correctly #24

Closed javmarina closed 8 years ago

javmarina commented 8 years ago

When the user clicks on a ListPreference with the menu mode set to simple menu, it shows with an alpha animation which differs from the framework animation (kind of zoom/scale).

consp1racy commented 8 years ago

Hello,

This is intended behavior.


How PopupWindow behaves on different platforms

On Android 6 I've observed that the popup fades in AND expands from the anchor view. Android N will even allow to customize this "epicenter". This would be the optimal behavior.

Android 5.x uses just fade in/out animation with no scaling or translation.

Android 4 expands either from top or bottom of anchor view. This is unwanted behavior since the menu is optimally presented with the selected item over the anchor view. The popup window is never exclusively above or under the anchor view which means the default animation looks out of place and quite frankly ugly.

In version 0.5.11 I had to do some pretty ugly computing to achieve next to perfect positioning so the concept of above or below is thrown out of the window and cannot be relied upon anyway.

I just tried these private Android animations with promising names

    <item name="android:windowEnterAnimation">@*android:anim/grow_fade_in_center</item>
    <item name="android:windowExitAnimation">@*android:anim/shrink_fade_out_center</item>

but the opening animaation played twice because of the aforementioned custom positioning (to satisfy curiosity on Android 5 it produced straight up mess).

If this really bugs you my suggestion is replacing the default animation everywhere since we're already going for that Material Design.


How PopupWIndow works

If you don't specify animation resource on a popup window it will use one of these (this is used by Android 4):

<style name="Animation.DropDownDown">
    <item name="windowEnterAnimation">@anim/grow_fade_in</item>
    <item name="windowExitAnimation">@anim/shrink_fade_out</item>
</style>

<style name="Animation.DropDownUp">
    <item name="windowEnterAnimation">@anim/grow_fade_in_from_bottom</item>
    <item name="windowExitAnimation">@anim/shrink_fade_out_from_bottom</item>
</style>

Since Android 5.x this one is specified as the default:

<style name="Animation.Material.Popup">
    <item name="windowEnterAnimation">@anim/popup_enter_material</item>
    <item name="windowExitAnimation">@anim/popup_exit_material</item>
</style>

That's just fade in, fade out. Android 6 added epicenter. Android N made it customizable.

consp1racy commented 8 years ago

Hi again, this is mended in v0.6.2. It fades and grows/shrinks on Android 2 and 4 and just fades on Android 5 and 6 so it's consistent with AOSP. It may not however be consistent with e.g. custom Samsung firmware on Android 2/4 so if you need to change this behavior, override

<style name="Animation.Asp.Popup" parent="..."> ... </style>