如何在启动应用程序时避免黑屏

gan*_*esh 13 android themes

当我最初启动我的应用程序时,我得到一个黑屏,在我的主要活动开始之前停留几秒钟.在iphone的情况下,显示名称默认的图像.我不确定如何在Android中做同样的事情.我试着如下徒劳:

         <activity android:name=".Index"
              android:label="@string/app_name"
              android:screenOrientation="portrait"
              android:theme="@drawable/defaultimage">
            <intent-filter>
              <action android:name="android.intent.action.MAIN" />
              <category android:name="android.intent.category.LAUNCHER" />
          </intent-filter>
        </activity>  
Run Code Online (Sandbox Code Playgroud)

YaW*_*YaW 15

我猜你对"索引"活动的onCreate方法进行了大量操作.

你应该把繁重的操作放在一个线程上并用图像制作一个闪屏,当线程完成后,加载菜单或你需要的任何东西.

例如,您可以制作"加载屏幕".使用Android非常简单:https://developer.android.com/guide/appendix/faq/commontasks.html#progressbarhttps://developer.android.com/reference/android/widget/ProgressBar.html

  • 我从http://android-developers.blogspot.com/2009/03/window-backgrounds-ui-speed.html得到了答案. (3认同)