【问题标题】:Why there is a white screen appears for 1sec when starting to run the apps in Android?为什么在Android中开始运行应用程序时会出现1秒的白屏?
【发布时间】:2012-09-18 18:10:15
【问题描述】:

当我单击应用程序图标并开始运行应用程序时,它会出现 1 秒钟的白屏。
我不知道为什么。
有没有办法清除这个白屏,直接进入我的活动?

【问题讨论】:

  • 可以贴一下启动应用时启动的activity的onCreate()吗?
  • 您是否执行任何任务,例如在第一次启动时初始化某些内容或下载某些内容?
  • 是的,但是我设置了progressdialog,但是还是白屏1秒,然后progressdialog
  • 发布您的onCreate() 进行第一次活动。

标签: android


【解决方案1】:

在您的 manifest.xml 文件中,为您的应用删除行 android:theme="@style/AppTheme"。再检查一遍

【讨论】:

    【解决方案2】:

    更改 style.xml 后:

    <resources>
    
        <style name="AppTheme" parent="android:Theme.Wallpaper" />
    
    </resources>
    

    有效!! 谢谢大家

    【讨论】:

    • 答案不清楚,因为您的问题没有讨论的背景。
    【解决方案3】:

    white/black 屏幕是窗口背景图片。

    窗口背景显示,例如您的 onCreate() 运行并且您的布局正在膨胀。这可能需要一些时间,尤其是在需要读取、解码和缩放大量位图的情况下。

    更改主题有效,因为某些主题具有非默认窗口背景。例如,Theme.Wallpaper has a transparent background。那里也有其他定义。基本上你想要的是:

    <style name="YourTheme">
      <item name="android:windowBackground">@null</item>
    </style>
    

    您可以通过编程实现同样的目的

    getWindow().setBackgroundDrawable(null);
    

    在活动顶部onCreate()

    (老问题,但被另一个答案撞倒了,没有一个好的答案。)

    【讨论】:

      【解决方案4】:

      在你的清单中使用这个标签:

      android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
      

      【讨论】:

        【解决方案5】:

        在对应activity的manifest文件中添加以下内容

         android:launchMode="standard"
        

        并从相应的活动中删除 android:label="@string/app_name" ,这实际上帮助了我

        【讨论】:

          【解决方案6】:

          只需在 AndroidManifest.xml 文件中提及启动 Activity 的透明主题即可。

          点赞:

          <activity
              android:name="first Activity Name"
              android:theme="@android:style/Theme.Translucent.NoTitleBar" >
          <intent-filter>
                  <action android:name="android.intent.action.MAIN" />
          
                  <category android:name="android.intent.category.LAUNCHER" />
              </intent-filter>
          

          【讨论】:

            【解决方案7】:

            设置。 File>Settings>Build,Deployment>Instant Run 取消选择那里显示的所有选项。

            并在您的 style.xml 中添加以下行

                <item name="android:windowDisablePreview">true</item>
             <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
                <!-- Customize your theme here. -->
                <item name="colorPrimary">@color/colorPrimary</item>
                <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
                <item name="colorAccent">@color/colorAccent</item>
                <item name="android:windowFullscreen">true</item>
                <item name="android:windowDisablePreview">true</item>
            </style>
            apply changes in AndroidMainfest.xml
             <application
                    android:theme="@style/AppTheme">
            

            【讨论】:

              【解决方案8】:

              就像你管..最初他们显示图标屏幕而不是白屏。并在 2 秒后显示主屏幕。

              首先在 res/drawable 中创建一个 XML drawable。

              <?xml version="1.0" encoding="utf-8"?>
              <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
              
                  <item
                      android:drawable="@color/gray"/>
              
                  <item>
                      <bitmap
                          android:gravity="center"
                          android:src="@mipmap/ic_launcher"/>
                  </item>
              
              </layer-list>
              

              接下来,您将在主题中将此设置为启动活动的背景。导航到您的 styles.xml 文件并为您的启动活动添加一个新主题

              <resources>
              
                  <!-- Base application theme. -->
                  <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
                      <!-- Customize your theme here. -->
                  </style>
              
                  <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
                      <item name="android:windowBackground">@drawable/background_splash</item>
                  </style>
              
              </resources>
              

              在您的新 SplashTheme 中,将窗口背景属性设置为您的 XML 可绘制对象。在 AndroidManifest.xml 中将其配置为启动活动的主题:

              <activity
                  android:name=".SplashActivity"
                  android:theme="@style/SplashTheme">
                  <intent-filter>
                      <action android:name="android.intent.action.MAIN" />
              
                      <category android:name="android.intent.category.LAUNCHER" />
                  </intent-filter>
              </activity>
              

              此链接提供您想要的。一步一步的程序。 https://www.bignerdranch.com/blog/splash-screens-the-right-way/

              【讨论】:

                【解决方案9】:

                在 Styles 中添加以下内容

                    <item name="android:windowFullscreen">true</item>
                    <item name="android:windowContentOverlay">@null</item>
                    <item name="android:windowIsTranslucent">true</item>
                

                希望这会帮助你并为我工作

                【讨论】:

                  猜你喜欢
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 2014-02-19
                  • 2019-10-01
                  • 1970-01-01
                  • 2019-07-28
                  • 1970-01-01
                  相关资源
                  最近更新 更多