Cómo arreglar la pantalla blanca en el inicio de la aplicación?


Tengo una aplicación para Android que muestra una pantalla blanca durante 2 segundos al inicio. Mis otras aplicaciones no hacen esto, pero esta sí. También he implementado un splashscreen con la esperanza de que solucionaría esto. ¿Debo aumentar el tiempo de sueño de mi pantalla de bienvenida? Gracias.

Author: buczek, 2013-12-12

13 answers

Simplemente mencione el tema transparente a la actividad inicial en el AndroidManifest.XML file.

Como:

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

Y extienda esa pantalla con la clase Activity en lugar de AppCompatActivity.

Como:

public class SplashScreenActivity extends Activity{

  ----YOUR CODE GOES HERE----
}
 93
Author: user543,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-07-25 10:29:20

Pon esto en un estilo personalizado y resuelve todos los problemas. El uso de la solución translúcida hacky hará que su barra de tareas y barra de navegación translúcida y hacer que la pantalla de salpicadura o pantalla principal se vea como espaguetis.

<item name="android:windowDisablePreview">true</item>

 138
Author: ireq,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-01-23 06:15:56

Crea un estilo en tu estilo.xml como sigue:

<style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowIsTranslucent">true</item>
</style>

Y úsalo con tu actividad en AndroidManifest como:

<activity android:name=".ActivitySplash" android:theme="@style/Theme.Transparent">
 63
Author: Tarun,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-27 06:56:00

introduzca la descripción de la imagen aquí

Como you tube.. inicialmente muestran la pantalla del icono en lugar de la pantalla blanca. Y después de 2 segundos muestra la pantalla de inicio.

Primero cree un elemento de diseño XML en res/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>

A continuación, establecerá esto como el fondo de su actividad splash en el tema. Navega a tus estilos.archivo xml y añadir un nuevo tema para su actividad 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>

En tu nuevo SplashTheme, establece el atributo window background en tu elemento de diseño XML. Configurar esto como el tema de tu actividad splash en tu 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>

Este enlace te da lo que quieres. procedimiento paso a paso. https://www.bignerdranch.com/blog/splash-screens-the-right-way /

ACTUALIZACIÓN:

El layer-list puede ser aún más simple como este (que también acepta elementos de diseño vectoriales para el logotipo centrado, a diferencia de la etiqueta <bitmap>):

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- Background color -->
    <item android:drawable="@color/gray"/>

    <!-- Logo at the center of the screen -->
    <item
        android:drawable="@mipmap/ic_launcher"
        android:gravity="center"/>
</layer-list>
 56
Author: Abhi,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-11-08 02:00:14

Usted debe leer este gran post de Cyril Mottier: Android App launching made gorgeous

Necesitas personalizar tu Theme con estilo.xml y evita personalizarlo en tu onCreate como barra de acción.setIcon / setTitle / etc.

Consulte también la Documentación sobre Consejos de rendimiento de Google.

Usa Trace View y Hierarchy Viewer para ver la hora de mostrar tus vistas: Optimización del rendimiento de Android / Ajuste De Rendimiento En Android

Use AsyncTask para mostrar algunas vistas.

 7
Author: Fllo,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-12-12 15:27:45

Este es mi tema de aplicación en una aplicación de ejemplo:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:windowIsTranslucent">true</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

Como puedes ver, tengo los colores predeterminados y luego agregué el android:windowIsTranslucent y lo establecí en true.

Por lo que sé como desarrollador de Android, esto es lo único que necesitas configurar para ocultar la pantalla blanca al inicio de la aplicación.

 5
Author: luiscosta,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-07-06 17:09:07

Ambas propiedades works utilizan cualquiera de ellas.

    <style name="AppBaseThemeDark" parent="@style/Theme.AppCompat">
            <!--your other properties -->
            <!--<item name="android:windowDisablePreview">true</item>-->
            <item name="android:windowBackground">@null</item>
            <!--your other properties -->
    </style>
 3
Author: Sohail Zahid,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-08-18 09:09:06

La respuesta de user543 es perfecta

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

Pero:

You'r LAUNCHER Activity debe extenderse Activity , no AppCompatActivity como vino por defecto!

 3
Author: Igor Fridman,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 11:47:18

El fondo blanco viene del Apptheme.Puede mostrar algo útil como el logotipo de su aplicación en lugar de blanco screen.it se puede hacer usando personalizado theme.in el tema de su aplicación solo tiene que añadir

android:windowBackground=""

Atributo. El valor del atributo puede ser una imagen o una lista de capas o cualquier color.

 2
Author: Rajesh.k,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-11-01 10:08:49

Se puede arreglar estableciendo el tema en su manifiesto como

<activity
        android:name=".MySplashActivityName"
        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>
</activity>

Y después de eso si usted está recibiendo
java.lang.IllegalStateException: Necesitas usar un tema.Tema AppCompat (o descendiente) con esta actividad.
entonces es posible que necesite extender Activity en lugar de AppCompatActivity en su MySplashActivity.

Espero que ayude!

 1
Author: Mr. Rabbit,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-06-30 13:21:56

Debe desactivar la configuración de Instant Run android Studio.

Archivo > Configuración > Compilación, Ejecución, Implementación > Ejecución instantánea Desmarque todas las opciones que se muestran allí.

Nota: Problema de pantalla blanca debido a Instant Run es solo para compilaciones de depuración,este problema no aparecerá en las compilaciones de versiones.

 0
Author: Mina Farid,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-23 10:05:49

A continuación se muestra el enlace que sugiere cómo diseñar la pantalla de bienvenida. Para evitar el fondo blanco / negro necesitamos definir un tema con fondo splash y establecer ese tema para splash en el archivo de manifiesto.

Https://android.jlelse.eu/right-way-to-create-splash-screen-on-android-e7f1709ba154

Splash_background.xml dentro de la carpeta res/drawable

<?xml version=”1.0" encoding=”utf-8"?>
 <layer-list xmlns:android=”http://schemas.android.com/apk/res/android">

 <item android:drawable=”@color/colorPrimary” />

 <item>
 <bitmap
 android:gravity=”center”
 android:src=”@mipmap/ic_launcher” />
 </item>

</layer-list>

Añadir debajo de los estilos

<!-- Base application theme. -->
    <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>
    </style>
    <!-- Splash Screen theme. -->
    <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="android:windowBackground">@drawable/splash_background</item>
    </style>

En el tema conjunto Manifiesto como se muestra a continuación

<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>
 0
Author: Rocky,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-02-06 10:48:16

También tuve el mismo problema en uno de mis proyectos. Lo resolví agregando algunos parámetros siguientes en el tema proporcionado a la pantalla de bienvenida.

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

Puedes encontrar la razón y la resolución en esta entrada de blog escrita por mí. Espero que ayude.

 0
Author: divaPrajapati09,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-06-24 09:35:58