可悲的是,这方面的信息很少,所以我还没有找到解决方案.当您打开活动时,将幻灯片过渡的持续时间设置得非常慢,可能会更加明显.@H_502_3@
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = activity.getWindow(); Slide slide = new Slide(); slide.setSlideEdge(Gravity.RIGHT); slide.excludeTarget(android.R.id.statusBarBackground,true); slide.excludeTarget(android.R.id.navigationBarBackground,true); window.setEnterTransition(slide); window.setExitTransition(slide); }
我的风格@H_502_3@
<!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light"> <!-- Customize your theme here. --> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="android:windowDrawsSystemBarBackgrounds">true</item> <item name="android:windowActivityTransitions">true</item> <item name="android:windowContentTransitions">true</item> <item name="android:windowAllowEnterTransitionOverlap">false</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowSoftInputMode">stateAlwaysHidden|adjustResize</item> </style>
解决方法
karaokyos的答案利用了前棒腑
活动过渡.这些转换定位到整个活动屏幕,并且不提供在转换期间排除屏幕部分的功能.@H_502_3@
约翰·欧内斯·瓜达卢佩(John Ernest Guadalupe)利用在棒棒糖(Activity& Fragment Transitions)中引入的转换.观察到的“白色屏幕”是窗口背景,即在转换期间正在褪色(more info about Activity & Fragment Transitions ).我想你在您的布局的根视图中设置您的活动的“黑色背景”?将窗口背景设置为黑色可以解决您的问题.@H_502_3@
编程方式:@H_502_3@
window.setBackgroundDrawable(new ColorDrawable(Color.BLACK));
<item name="android:windowBackground">@android:color/black</item>
这是由此产生的过渡.@H_502_3@
@H_502_3@
编辑:如何提供required滑出(左)转换的呼叫活动@H_502_3@
第一个活动:@H_502_3@
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); Slide slide = new Slide(); slide.setInterpolator(new LinearInterpolator()); slide.setSlideEdge(Gravity.LEFT); slide.excludeTarget(android.R.id.statusBarBackground,true); slide.excludeTarget(android.R.id.navigationBarBackground,true); window.setExitTransition(slide); // The Transition to use to move Views out of the scene when calling a new Activity. window.setReenterTransition(slide); // The Transition to use to move Views into the scene when reentering from a prevIoUsly-started Activity. window.setBackgroundDrawable(new ColorDrawable(Color.BLACK)); }
第二活动:@H_502_3@
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); Slide slide = new Slide(); slide.setInterpolator(new LinearInterpolator()); slide.setSlideEdge(Gravity.RIGHT); slide.excludeTarget(android.R.id.statusBarBackground,true); window.setEnterTransition(slide); // The Transition to use to move Views into the initial Scene. window.setReturnTransition(slide); // The Transition to use to move Views out of the Scene when the Window is preparing to close. window.setBackgroundDrawable(new ColorDrawable(Color.BLACK)); }
您可以尝试不同的内插器来改变转换的速度.@H_502_3@
LinearInterpolator的最终过渡:@H_502_3@
@H_502_3@
如果你想摆脱第一个幻灯片和第二个活动的幻灯片之间的差距,你可以设置:@H_502_3@
<item name="android:windowAllowEnterTransitionOverlap">true</item>
如何调试转换:@H_502_3@
It can become a lot more apparent when you set a very slow duration to the Slide transition when opening an activity.@H_502_3@
为了(视觉)调试转换,在开发设置中有3个选项(“窗口动画缩放”,“过渡动画缩放”,“动画持续时间缩放”),以乘以所有转换/动画的持续时间.@H_502_3@