Window animation overlaps navigation bar on Android 5.0

旧时模样 提交于 2019-12-03 07:10:22

问题


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?


回答1:


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.




回答2:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!