How can i exclude ActionBar when transitions between Activities on Android 5.0

前端 未结 2 2076
孤街浪徒
孤街浪徒 2020-12-09 21:56

On Android 5.0 Lollipop,

I have two activities A and B. Activity B has a slie enter transition from bottom with a Overlay ActionBar, but when B shows, the ActionBar

2条回答
  •  攒了一身酷
    2020-12-09 22:40

    If you are using the AppCompat v7 library, it is easy:

    View decor = getWindow().getDecorView();
    int actionBarId = R.id.action_bar_container;
    enterTransition.excludeTarget(decor.findViewById(actionBarId), true);
    

    Unfortunately, the action bar container view ID is not part of the public API, so if you are not using the AppCompat v7 library (i.e. you are using the official framework libraries) you will need to work around this by using the following code to retrieve the ID instead:

    int actionBarId = getResources().getIdentifier("action_bar_container", "id", "android");
    

    Note that this code will break if the action bar container's ID name changes in a future version of Android. I doubt it will ever change though...

    See this post for some other related information.

提交回复
热议问题