[英]Slide not working in api level 21 and above
I am working on one application and I implement Slide animation but it's not working at all any idea what's wrong with the implementation. 我正在开发一个应用程序,并且实现了Slide动画,但是它根本不起作用。
@Override
protected void onCreate(Bundle savedInstanceState)
{
getApplicationContext().setTheme(R.style.MyTheme);
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
Slide slide = new Slide();
slide.setDuration(10000);
getWindow().setExitTransition(slide);
super.onCreate(savedInstanceState);
this.context = SplashActivity.this;
setContentView(R.layout.activity_splash);
}
Below is the Style: 以下是样式:
<style name="MyTheme" parent="android:Theme.Light.NoTitleBar">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:windowContentTransitions">true</item>
</style>
Intent through move another activity. 意图通过移动另一项活动。
Intent i = new Intent(SplashActivity.this, OnBoardingActivity.class);
ActivityOptions transition = ActivityOptions.makeSceneTransitionAnimation(SplashActivity.this);
startActivity(i, transition.toBundle());
Another activity. 另一项活动。
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Fade fade = new Fade();
fade.setDuration(10000);
getWindow().setEnterTransition(fade);
setContentView(R.layout.activity_onboarding);
}
I found the solution.Just change the theme with Appcompat support theme and its working fine. 我找到了解决方案,只需使用Appcompat支持主题更改主题即可,并且可以正常使用。
<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentNavigation">false</item>
</style>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.