我可以避免再次调用setTheme吗?

时间:2019-05-11 16:49:17

标签: android splash-screen

我已经为我的应用制作了一个启动屏幕,我看到来自启动屏幕的图像仍然是布局背景图像。

因此,为了解决此问题,我在onCreate方法内调用了setTheme,希望他们像这样:

   @Override
protected void onCreate(Bundle savedInstanceState) {       
    this.setTheme(R.style.AppTheme); //change the them after the splash screen ended so the activity bacground will get fixed.
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_loging_with_phone);
}

在清单中声明this.setTheme(R.style.AppTheme)后,有什么方法可以避免调用它们?难道我做错了什么?


这是我制作启动画面的方式:

创建样式:

<style name="splashScreenTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowBackground">@mipmap/app_icon</item>
</style>

将此样式添加到清单中的活动

 <activity android:name=".LogingWithPhoneActivity"
        android:theme="@style/splashScreenTheme">

仅此而已,以及为什么会发生这种情况的想法?


0 个答案:

没有答案
相关问题