活动更改后,我想锁定工具栏。
可以使用片段吗?
还是什么方式?
我想要这个过程
最佳答案
您可以使用共享元素过渡并添加工具栏和状态栏。
Transition fade = new Fade();
fade.excludeTarget(android.R.id.statusBarBackground, true);
fade.excludeTarget(android.R.id.navigationBarBackground, true);
getWindow().setExitTransition(fade);
getWindow().setEnterTransition(fade);
也可以使用XML在活动的主题中声明此过渡(即,在您自己的res / transition / window_fade.xml文件中):
<?xml version="1.0" encoding="utf-8"?>
<fade xmlns:android="http://schemas.android.com/apk/res/android">
<targets>
<target android:excludeId="@android:id/statusBarBackground"/>
<target android:excludeId="@android:id/navigationBarBackground"/>
</targets>
</fade>
还有其他好的答案,请点击此处How do I prevent the status bar and navigation bar from animating during an activity scene animation transition?