在Android 5.0上的Activity之间进行转换时,如何排除ActionBar [英] How can i exclude ActionBar when transitions between Activities on Android 5.0

本文介绍了在Android 5.0上的Activity之间进行转换时,如何排除ActionBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android 5.0 Lollipop上,

On Android 5.0 Lollipop,

我有两个活动A和B.活动B的底部有一个输入框,上面有一个叠加式ActionBar,但是当B显示时,ActionBar也从下往上滑动.

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 also slide from bottom to top.

如何防止操作栏滑动过渡.系统操作栏是否具有可以添加到排除目标的ID?

How can i prevent the actionbar from slide transition. does system actionbar has an id that i can add to the exclude target ?

谢谢!

推荐答案

如果您使用的是AppCompat v7库,则很容易:

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);

不幸的是,操作栏容器视图ID不是公共API的一部分,因此,如果您不使用AppCompat v7库(即,您使用的是官方框架库),则需要使用以下方法来解决此问题取而代之的是获取ID的代码:

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");

请注意,如果操作栏容器的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.

这篇关于在Android 5.0上的Activity之间进行转换时,如何排除ActionBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆