Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 为什么在安卓系统中开始运行应用程序时会出现1秒钟的白色屏幕?_Android - Fatal编程技术网

Android 为什么在安卓系统中开始运行应用程序时会出现1秒钟的白色屏幕?

Android 为什么在安卓系统中开始运行应用程序时会出现1秒钟的白色屏幕?,android,Android,当我单击应用程序图标并开始运行应用程序时,它将显示一个白色屏幕,持续1秒。 我不知道为什么。 有没有办法清除这个白色屏幕并直接进入我的活动?在你的manifest.xml文件中删除你的应用程序的行android:theme=“@style/AppTheme”。并在我更改style.xml后再次检查它: <resources> <style name="AppTheme" parent="android:Theme.Wallpaper" /> </reso

当我单击应用程序图标并开始运行应用程序时,它将显示一个白色屏幕,持续1秒。
我不知道为什么。

有没有办法清除这个白色屏幕并直接进入我的活动?

在你的
manifest.xml
文件中删除你的应用程序的行
android:theme=“@style/AppTheme”
。并在我更改style.xml后再次检查它:

<resources>

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

</resources>

它起作用了!! 谢谢大家

屏幕是窗口背景图像

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

更改主题会起作用,因为某些主题具有非默认窗口背景。例如还有其他的定义。基本上你想要的是:

<style name="YourTheme">
  <item name="android:windowBackground">@null</item>
</style>
在活动的顶部
onCreate()


(这是一个老问题,但被另一个答案打断了,没有一个好答案。)

在清单中使用此标签:

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

在相应活动的清单文件中添加以下内容

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

在AndroidManifest.xml文件中将透明主题提到起始活动。 比如:
设置。文件>设置>构建、部署>即时运行取消选择此处显示的所有选项

并在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">
true
@颜色/原色
@颜色/原色暗
@颜色/颜色重音
真的
真的
在AndroidMainfest.xml中应用更改
就像你管的。。最初,它们显示图标屏幕而不是白色屏幕。2秒后显示主屏幕

首先在res/drawable中创建一个XML可绘制文件

<?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>

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

<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>

@可绘制/背景\u飞溅
在新的SplashTheme中,将“窗口背景”属性设置为XML drawable。在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>

在样式中添加以下内容

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

希望这对你和我的工作有所帮助

你能发布启动应用程序时启动的活动的onCreate()吗?你是否执行过任何任务,比如在第一次启动时初始化或下载某些内容?是的,但我已设置了progressdialog,但它仍会显示1秒钟的白色屏幕,然后progressdialogPost您的
onCreate()
作为第一个活动。由于您的问题与您的讨论内容无关,因此答案不清楚。
<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>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowIsTranslucent">true</item>