我正在处理一个应用程序,并且我实现了幻灯片动画,但它根本不知道实现的错误。
@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);
}
以下是风格:
<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 i = new Intent(SplashActivity.this, OnBoardingActivity.class);
ActivityOptions transition = ActivityOptions.makeSceneTransitionAnimation(SplashActivity.this);
startActivity(i, transition.toBundle());
另一项活动。
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Fade fade = new Fade();
fade.setDuration(10000);
getWindow().setEnterTransition(fade);
setContentView(R.layout.activity_onboarding);
}
答案 0 :(得分:0)
我找到了解决方案。只需使用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>