Android - 禁用应用程序的虚拟启动窗口

urS*_*Sus 14 android window startup

我想知道如何实现这种效果.

我的应用程序(默认所有内容),当点击启动器图标时,立即显示某种空的虚拟窗口,其中没有任何事情发生,然后将布局加载到其中.

"重型"应用程序,如YouTube,云端硬盘,Dropbox等,在启动时似乎等待启动后,没有显示虚拟窗口并加载到准备好的布局中.

知道怎么做或者我应该在哪里研究?

谢谢

//编辑:这与加载数据库之类的东西无关,我应该在其中显示progressBar,imho这与活动存在之前的东西有关.

JDC*_*der 24

我建议您不要使用以下方法禁用虚拟加载窗口:

<style name="Theme.MyTheme" parent="android:style/Theme" >
    ....
    <item name="android:windowDisablePreview">true</item>
    ....
</style>
Run Code Online (Sandbox Code Playgroud)

因为你可能遇到几个问题.例如,如果您尝试为AlertDialog设置动画,则输入动画将无效(个人体验).

正确的解决方案是将应用程序的主题设置为主活动屏幕(相同的ActionBar样式,相同的背景颜色).经过多次实验,我的应用程序中找到了满足我需求的正确解决方案.(我有一个空白背景的主要活动,没有ActionBar,只是全屏个人布局)

1 - styles.xml:添加这样的新样式(删除ActionBar并设置我的主要活动的相同背景颜色)

<style name="LoadingTheme" parent="@android:style/Theme.Light.NoTitleBar.Fullscreen">
    <item name="android:windowBackground">@color/white_smoke</item>
</style>
Run Code Online (Sandbox Code Playgroud)

2 - AndroidManifest.xml:将主要活动的主题设置为"LoadingTheme"

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
        <activity
            android:name="com.company.appname.MainActivity"
            android:label="@string/app_name"
            android:theme="@style/LoadingTheme">
        <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
    </activity>
    ....
</application>
Run Code Online (Sandbox Code Playgroud)

最后我有一个完整的空白虚拟加载窗口,没有带有软MainActivity负载和工作动画的ActionBar.

希望对你有所帮助.


urS*_*Sus 10

<style name="Theme.MyTheme" parent="android:style/Theme" >
    ....
    <item name="android:windowDisablePreview">true</item>
    ....
</style>
Run Code Online (Sandbox Code Playgroud)

但请谨慎使用