I'm implementing the Material Design bottom sheet design pattern in my app using a custom subclass of Dialog
. The dialog is gravitated to the bottom of the screen and uses an y-translation window enter animation:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/decelerate_cubic">
<translate android:fromYDelta="100%"
android:toYDelta="0"
android:duration="250" />
</set>
On earlier versions of Android, this looks great (if I say so myself): the dialog smoothly slides in from the bottom of the screen and from under the navigation bar.
However, on the latest 5.0 preview image, window animations happen on top of the navigation bar, so the dialog contents temporarily overlap the navigation. With this particular use case it looks ugly, strange and distracting.
Is there anything I can set in my theme or code to prevent this?
Just use
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
for activity where you show your dialog. In this case your dialog will be under navigation bar during animation.
From the android developers website:
In this release, Android introduces a new Toolbar widget. This is a generalization of the Action Bar pattern that gives you much more control and flexibility. Toolbar is a view in your hierarchy just like any other, making it easier to interleave with the rest of your views, animate it, and react to scroll events. You can also set it as your Activity’s action bar, meaning that your standard options menu actions will be display within it.
So the actionbar is now a view in your layout, that's why the popup goes over it. I also know they introduced some z-index properties, it might be helpful for you.
来源:https://stackoverflow.com/questions/26624406/window-animation-overlaps-navigation-bar-on-android-5-0