blank screen comes before splashHow To fix white screen on app Start up?Get screen dimensions in pixelsHow to align views at the bottom of the screen?Bug: onNewIntent not called for singleTop activity with Intent.FLAG_ACTIVITY_NEW_TASKHow do I make a splash screen?Getting an exception when app startsNo video display when playing an mp4 file on AndroidPhonegap: blank page before showing splash screenHow to make setContentView() work properly with a thread?splash screen shown as blank screenReact-native Android Splashscreen - Custom fonts
Should one buy new hardware after a system compromise?
Would Brexit have gone ahead by now if Gina Miller had not forced the Government to involve Parliament?
How to execute this code on startup?
When and what was the first 3D acceleration device ever released?
My employer faked my resume to acquire projects
Pirate democracy at its finest
Is it unethical to use a published code in my PhD thesis work?
What are these arcade games in Ghostbusters 1984?
What is quasi-aromaticity?
How should I introduce map drawing to my players?
Why do Ryanair allow me to book connecting itineraries through a third party, but not through their own website?
Why were helmets and other body armour not commonplace in the 1800s?
Make 24 using exactly three 3s
Simple function that simulates survey results based on sample size and probability
I think I may have violated academic integrity last year - what should I do?
How to use " shadow " in pstricks?
Is CD audio quality good enough?
Does the unit of measure matter when you are solving for the diameter of a circumference?
Computing the matrix powers of a non-diagonalizable matrix
Image processing: Removal of two spots in fundus images
Adding spaces to string based on list
Why does this if-statement combining assignment and an equality check return true?
Text at the right of icon
Construct a word ladder
blank screen comes before splash
How To fix white screen on app Start up?Get screen dimensions in pixelsHow to align views at the bottom of the screen?Bug: onNewIntent not called for singleTop activity with Intent.FLAG_ACTIVITY_NEW_TASKHow do I make a splash screen?Getting an exception when app startsNo video display when playing an mp4 file on AndroidPhonegap: blank page before showing splash screenHow to make setContentView() work properly with a thread?splash screen shown as blank screenReact-native Android Splashscreen - Custom fonts
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
The main problem is the splash screen appears after 2-3 seconds. Before splash screen a blank layout appears which I don't want. Otherwise it runs fine. Just want to remove the blank layout which appears before the splash page.
MainActivity:
public class MainActivity extends Activity
private static String TAG = MainActivity.class.getName();
private static long SLEEP_TIME = 5; // Sleep for some time
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE); // Removes title bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // Removes notification bar
setContentView(R.layout.activity_main);
// Start timer and launch main activity
IntentLauncher launcher = new IntentLauncher();
launcher.start();
private class IntentLauncher extends Thread
@Override
/**
* Sleep for some time and than start new activity.
*/
public void run()
try
// Sleeping
Thread.sleep(SLEEP_TIME*1000);
catch (Exception e)
Log.e(TAG, e.getMessage());
// Start main activity
Intent intent = new Intent(MainActivity.this, Login.class);
MainActivity.this.startActivity(intent);
MainActivity.this.finish();
main layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/splash"
tools:context=".MainActivity" >
</RelativeLayout>
android splash-screen
add a comment |
The main problem is the splash screen appears after 2-3 seconds. Before splash screen a blank layout appears which I don't want. Otherwise it runs fine. Just want to remove the blank layout which appears before the splash page.
MainActivity:
public class MainActivity extends Activity
private static String TAG = MainActivity.class.getName();
private static long SLEEP_TIME = 5; // Sleep for some time
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE); // Removes title bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // Removes notification bar
setContentView(R.layout.activity_main);
// Start timer and launch main activity
IntentLauncher launcher = new IntentLauncher();
launcher.start();
private class IntentLauncher extends Thread
@Override
/**
* Sleep for some time and than start new activity.
*/
public void run()
try
// Sleeping
Thread.sleep(SLEEP_TIME*1000);
catch (Exception e)
Log.e(TAG, e.getMessage());
// Start main activity
Intent intent = new Intent(MainActivity.this, Login.class);
MainActivity.this.startActivity(intent);
MainActivity.this.finish();
main layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/splash"
tools:context=".MainActivity" >
</RelativeLayout>
android splash-screen
1
possible duplicate of How To fix white screen on app Start up?
– JPS
May 20 '15 at 7:28
1
Why splash screens ? What's so good about a screen in your software that does nothing but make the user wait for your app to start ?
– 2Dee
May 20 '15 at 7:31
add a comment |
The main problem is the splash screen appears after 2-3 seconds. Before splash screen a blank layout appears which I don't want. Otherwise it runs fine. Just want to remove the blank layout which appears before the splash page.
MainActivity:
public class MainActivity extends Activity
private static String TAG = MainActivity.class.getName();
private static long SLEEP_TIME = 5; // Sleep for some time
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE); // Removes title bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // Removes notification bar
setContentView(R.layout.activity_main);
// Start timer and launch main activity
IntentLauncher launcher = new IntentLauncher();
launcher.start();
private class IntentLauncher extends Thread
@Override
/**
* Sleep for some time and than start new activity.
*/
public void run()
try
// Sleeping
Thread.sleep(SLEEP_TIME*1000);
catch (Exception e)
Log.e(TAG, e.getMessage());
// Start main activity
Intent intent = new Intent(MainActivity.this, Login.class);
MainActivity.this.startActivity(intent);
MainActivity.this.finish();
main layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/splash"
tools:context=".MainActivity" >
</RelativeLayout>
android splash-screen
The main problem is the splash screen appears after 2-3 seconds. Before splash screen a blank layout appears which I don't want. Otherwise it runs fine. Just want to remove the blank layout which appears before the splash page.
MainActivity:
public class MainActivity extends Activity
private static String TAG = MainActivity.class.getName();
private static long SLEEP_TIME = 5; // Sleep for some time
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE); // Removes title bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // Removes notification bar
setContentView(R.layout.activity_main);
// Start timer and launch main activity
IntentLauncher launcher = new IntentLauncher();
launcher.start();
private class IntentLauncher extends Thread
@Override
/**
* Sleep for some time and than start new activity.
*/
public void run()
try
// Sleeping
Thread.sleep(SLEEP_TIME*1000);
catch (Exception e)
Log.e(TAG, e.getMessage());
// Start main activity
Intent intent = new Intent(MainActivity.this, Login.class);
MainActivity.this.startActivity(intent);
MainActivity.this.finish();
main layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/splash"
tools:context=".MainActivity" >
</RelativeLayout>
android splash-screen
android splash-screen
edited Apr 2 '17 at 12:20
Fahad Rehman
643620
643620
asked May 20 '15 at 7:24
Somnath PalSomnath Pal
73011328
73011328
1
possible duplicate of How To fix white screen on app Start up?
– JPS
May 20 '15 at 7:28
1
Why splash screens ? What's so good about a screen in your software that does nothing but make the user wait for your app to start ?
– 2Dee
May 20 '15 at 7:31
add a comment |
1
possible duplicate of How To fix white screen on app Start up?
– JPS
May 20 '15 at 7:28
1
Why splash screens ? What's so good about a screen in your software that does nothing but make the user wait for your app to start ?
– 2Dee
May 20 '15 at 7:31
1
1
possible duplicate of How To fix white screen on app Start up?
– JPS
May 20 '15 at 7:28
possible duplicate of How To fix white screen on app Start up?
– JPS
May 20 '15 at 7:28
1
1
Why splash screens ? What's so good about a screen in your software that does nothing but make the user wait for your app to start ?
– 2Dee
May 20 '15 at 7:31
Why splash screens ? What's so good about a screen in your software that does nothing but make the user wait for your app to start ?
– 2Dee
May 20 '15 at 7:31
add a comment |
8 Answers
8
active
oldest
votes
Generally speaking, splash screens are not recommended for an app but if you really must.
Android will load a blank layout before it loads an activity layout based on the theme you have set for it. The solution is to set the theme of the splash activity to a transparent one.
Create a transparent theme in res/values/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
Then set the theme in your manifest
<activity android:name=".SplashActivity" android:theme="@style/Theme.Transparent">
...
</activity>
You have update your styles.xml to this <style name="Theme.MyTheme" android:theme="@style/Theme.Transparent"> <item name="android:windowDisablePreview">true</item> </style>
– silentsudo
May 20 '15 at 7:38
This theme doesn't work with AppCompatActivity, As well as, it doesn't remove the status bar.
– Narendra Singh
Aug 16 '16 at 6:05
add a comment |
It's better to use a Themed background for your starting activity but if you don't want the blank screen appears before launching main activity you can define your activity like this:
Add android:windowDisablePreview
to your AppTheme in res/values/styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme">
<item name="android:windowDisablePreview">true</item>
</style>
</resources>
Then set your activity theme in your manifest:
<activity android:name=".MainActivity" android:theme="@style/AppTheme">
...
</activity>
P.S: Setting android:windowDisablePreview
has no effect on your activity background, so you have nothing to worry.
Thanks,It solved my problem
– kavie
Jul 16 '18 at 7:17
add a comment |
Just mention the transparent theme to the starting activity in the AndroidManifest.xml file.
<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>
add a comment |
The problem you are facing here is called 'cold start' and it's the time mostly spent in your Application.onCreate
method, which usually does some initialisations and it might take longer than you wish. You can read here the official documentation: https://developer.android.com/topic/performance/launch-time.html
If this is the case than setting the theme to translucent or disabling preview as others suggested will only apparently solve the issue, because in reality you will try to launch the app and you won't receive any feedback about the fact the you tapped the app icon. You will see your app starting with a delay, which is not a desired UX.
Blank, black or white screen, it really depends on the android:windowBackground
attribute specified in your main activity theme.
The best you can do, apart from moving some of the initialisations that you probably are doing in your Application.onCreate
method, is to brand your preview window with a logo as suggested in this post:
https://plus.google.com/+AndroidDevelopers/posts/Z1Wwainpjhd
You can go further and improve the user experience by animating your logo image in a splash screen, if it's the case, or by designing the preview window in a way that can be smooth transitioned to your main activity content, like described here:
http://saulmm.github.io/avoding-android-cold-starts
Same question is answered correctly here: https://stackoverflow.com/a/40482549/7094200 and described in this blog post: https://www.bignerdranch.com/blog/splash-screens-the-right-way/
add a comment |
Really! the below link work for me!!!!
https://cyrilmottier.com/2013/01/23/android-app-launching-made-gorgeous/
write the separate style in style.xml for your splash screen so that you can co-relate both the screen.
Herein the style:
<style name="AppTheme.Splash" parent="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/splash_final</item>
</style>
add a comment |
It' s android features. You can change background color of your blankscreen. Use style:
<resources>
<style name="Theme" parent="android:style/Theme" />
<style name="Theme.MainTheme" parent="Theme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@drawable/background_drawable</item>
</style>
</resources>
then use it in manifest:
<application
android:name="@string/app_name"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.MainTheme"
>
add a comment |
I fixed mine by just updating the build tools in Android Studio.
add a comment |
I think this is similar to some answers that have been posted above. I still would like to recommend the following Big Nerd Ranch guide on how to create a splash screen the right way because its well illustrated and easy to follow. You should really go there and read it instead of continuing below :).
https://www.bignerdranch.com/blog/splash-screens-the-right-way/
But in short what it suggests is, at app start you launch an initial splash activity. For this activity you create an XML drawable (@drawable/background_splash
).
<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>
Then you create a theme for splash activity’s and set the drawable you created above as its window background.
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/background_splash</item>
</style>
And then in the manifest you tell the splash activity to use the above theme.
<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>
Finally in your splash activity implement theonCreate
method like below (thats all the code you need in the activity). This will launch your main activity and finish the splash activity:
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f30342933%2fblank-screen-comes-before-splash%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
8 Answers
8
active
oldest
votes
8 Answers
8
active
oldest
votes
active
oldest
votes
active
oldest
votes
Generally speaking, splash screens are not recommended for an app but if you really must.
Android will load a blank layout before it loads an activity layout based on the theme you have set for it. The solution is to set the theme of the splash activity to a transparent one.
Create a transparent theme in res/values/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
Then set the theme in your manifest
<activity android:name=".SplashActivity" android:theme="@style/Theme.Transparent">
...
</activity>
You have update your styles.xml to this <style name="Theme.MyTheme" android:theme="@style/Theme.Transparent"> <item name="android:windowDisablePreview">true</item> </style>
– silentsudo
May 20 '15 at 7:38
This theme doesn't work with AppCompatActivity, As well as, it doesn't remove the status bar.
– Narendra Singh
Aug 16 '16 at 6:05
add a comment |
Generally speaking, splash screens are not recommended for an app but if you really must.
Android will load a blank layout before it loads an activity layout based on the theme you have set for it. The solution is to set the theme of the splash activity to a transparent one.
Create a transparent theme in res/values/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
Then set the theme in your manifest
<activity android:name=".SplashActivity" android:theme="@style/Theme.Transparent">
...
</activity>
You have update your styles.xml to this <style name="Theme.MyTheme" android:theme="@style/Theme.Transparent"> <item name="android:windowDisablePreview">true</item> </style>
– silentsudo
May 20 '15 at 7:38
This theme doesn't work with AppCompatActivity, As well as, it doesn't remove the status bar.
– Narendra Singh
Aug 16 '16 at 6:05
add a comment |
Generally speaking, splash screens are not recommended for an app but if you really must.
Android will load a blank layout before it loads an activity layout based on the theme you have set for it. The solution is to set the theme of the splash activity to a transparent one.
Create a transparent theme in res/values/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
Then set the theme in your manifest
<activity android:name=".SplashActivity" android:theme="@style/Theme.Transparent">
...
</activity>
Generally speaking, splash screens are not recommended for an app but if you really must.
Android will load a blank layout before it loads an activity layout based on the theme you have set for it. The solution is to set the theme of the splash activity to a transparent one.
Create a transparent theme in res/values/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
Then set the theme in your manifest
<activity android:name=".SplashActivity" android:theme="@style/Theme.Transparent">
...
</activity>
edited Mar 24 at 5:07
Dhaval Pujara
1117
1117
answered May 20 '15 at 7:29
EoinEoin
2,85712139
2,85712139
You have update your styles.xml to this <style name="Theme.MyTheme" android:theme="@style/Theme.Transparent"> <item name="android:windowDisablePreview">true</item> </style>
– silentsudo
May 20 '15 at 7:38
This theme doesn't work with AppCompatActivity, As well as, it doesn't remove the status bar.
– Narendra Singh
Aug 16 '16 at 6:05
add a comment |
You have update your styles.xml to this <style name="Theme.MyTheme" android:theme="@style/Theme.Transparent"> <item name="android:windowDisablePreview">true</item> </style>
– silentsudo
May 20 '15 at 7:38
This theme doesn't work with AppCompatActivity, As well as, it doesn't remove the status bar.
– Narendra Singh
Aug 16 '16 at 6:05
You have update your styles.xml to this <style name="Theme.MyTheme" android:theme="@style/Theme.Transparent"> <item name="android:windowDisablePreview">true</item> </style>
– silentsudo
May 20 '15 at 7:38
You have update your styles.xml to this <style name="Theme.MyTheme" android:theme="@style/Theme.Transparent"> <item name="android:windowDisablePreview">true</item> </style>
– silentsudo
May 20 '15 at 7:38
This theme doesn't work with AppCompatActivity, As well as, it doesn't remove the status bar.
– Narendra Singh
Aug 16 '16 at 6:05
This theme doesn't work with AppCompatActivity, As well as, it doesn't remove the status bar.
– Narendra Singh
Aug 16 '16 at 6:05
add a comment |
It's better to use a Themed background for your starting activity but if you don't want the blank screen appears before launching main activity you can define your activity like this:
Add android:windowDisablePreview
to your AppTheme in res/values/styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme">
<item name="android:windowDisablePreview">true</item>
</style>
</resources>
Then set your activity theme in your manifest:
<activity android:name=".MainActivity" android:theme="@style/AppTheme">
...
</activity>
P.S: Setting android:windowDisablePreview
has no effect on your activity background, so you have nothing to worry.
Thanks,It solved my problem
– kavie
Jul 16 '18 at 7:17
add a comment |
It's better to use a Themed background for your starting activity but if you don't want the blank screen appears before launching main activity you can define your activity like this:
Add android:windowDisablePreview
to your AppTheme in res/values/styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme">
<item name="android:windowDisablePreview">true</item>
</style>
</resources>
Then set your activity theme in your manifest:
<activity android:name=".MainActivity" android:theme="@style/AppTheme">
...
</activity>
P.S: Setting android:windowDisablePreview
has no effect on your activity background, so you have nothing to worry.
Thanks,It solved my problem
– kavie
Jul 16 '18 at 7:17
add a comment |
It's better to use a Themed background for your starting activity but if you don't want the blank screen appears before launching main activity you can define your activity like this:
Add android:windowDisablePreview
to your AppTheme in res/values/styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme">
<item name="android:windowDisablePreview">true</item>
</style>
</resources>
Then set your activity theme in your manifest:
<activity android:name=".MainActivity" android:theme="@style/AppTheme">
...
</activity>
P.S: Setting android:windowDisablePreview
has no effect on your activity background, so you have nothing to worry.
It's better to use a Themed background for your starting activity but if you don't want the blank screen appears before launching main activity you can define your activity like this:
Add android:windowDisablePreview
to your AppTheme in res/values/styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme">
<item name="android:windowDisablePreview">true</item>
</style>
</resources>
Then set your activity theme in your manifest:
<activity android:name=".MainActivity" android:theme="@style/AppTheme">
...
</activity>
P.S: Setting android:windowDisablePreview
has no effect on your activity background, so you have nothing to worry.
answered Apr 27 '17 at 16:59
Keivan EsbatiKeivan Esbati
1,83611028
1,83611028
Thanks,It solved my problem
– kavie
Jul 16 '18 at 7:17
add a comment |
Thanks,It solved my problem
– kavie
Jul 16 '18 at 7:17
Thanks,It solved my problem
– kavie
Jul 16 '18 at 7:17
Thanks,It solved my problem
– kavie
Jul 16 '18 at 7:17
add a comment |
Just mention the transparent theme to the starting activity in the AndroidManifest.xml file.
<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>
add a comment |
Just mention the transparent theme to the starting activity in the AndroidManifest.xml file.
<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>
add a comment |
Just mention the transparent theme to the starting activity in the AndroidManifest.xml file.
<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>
Just mention the transparent theme to the starting activity in the AndroidManifest.xml file.
<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>
answered May 20 '15 at 7:28
Narendra SinghNarendra Singh
3,05932671
3,05932671
add a comment |
add a comment |
The problem you are facing here is called 'cold start' and it's the time mostly spent in your Application.onCreate
method, which usually does some initialisations and it might take longer than you wish. You can read here the official documentation: https://developer.android.com/topic/performance/launch-time.html
If this is the case than setting the theme to translucent or disabling preview as others suggested will only apparently solve the issue, because in reality you will try to launch the app and you won't receive any feedback about the fact the you tapped the app icon. You will see your app starting with a delay, which is not a desired UX.
Blank, black or white screen, it really depends on the android:windowBackground
attribute specified in your main activity theme.
The best you can do, apart from moving some of the initialisations that you probably are doing in your Application.onCreate
method, is to brand your preview window with a logo as suggested in this post:
https://plus.google.com/+AndroidDevelopers/posts/Z1Wwainpjhd
You can go further and improve the user experience by animating your logo image in a splash screen, if it's the case, or by designing the preview window in a way that can be smooth transitioned to your main activity content, like described here:
http://saulmm.github.io/avoding-android-cold-starts
Same question is answered correctly here: https://stackoverflow.com/a/40482549/7094200 and described in this blog post: https://www.bignerdranch.com/blog/splash-screens-the-right-way/
add a comment |
The problem you are facing here is called 'cold start' and it's the time mostly spent in your Application.onCreate
method, which usually does some initialisations and it might take longer than you wish. You can read here the official documentation: https://developer.android.com/topic/performance/launch-time.html
If this is the case than setting the theme to translucent or disabling preview as others suggested will only apparently solve the issue, because in reality you will try to launch the app and you won't receive any feedback about the fact the you tapped the app icon. You will see your app starting with a delay, which is not a desired UX.
Blank, black or white screen, it really depends on the android:windowBackground
attribute specified in your main activity theme.
The best you can do, apart from moving some of the initialisations that you probably are doing in your Application.onCreate
method, is to brand your preview window with a logo as suggested in this post:
https://plus.google.com/+AndroidDevelopers/posts/Z1Wwainpjhd
You can go further and improve the user experience by animating your logo image in a splash screen, if it's the case, or by designing the preview window in a way that can be smooth transitioned to your main activity content, like described here:
http://saulmm.github.io/avoding-android-cold-starts
Same question is answered correctly here: https://stackoverflow.com/a/40482549/7094200 and described in this blog post: https://www.bignerdranch.com/blog/splash-screens-the-right-way/
add a comment |
The problem you are facing here is called 'cold start' and it's the time mostly spent in your Application.onCreate
method, which usually does some initialisations and it might take longer than you wish. You can read here the official documentation: https://developer.android.com/topic/performance/launch-time.html
If this is the case than setting the theme to translucent or disabling preview as others suggested will only apparently solve the issue, because in reality you will try to launch the app and you won't receive any feedback about the fact the you tapped the app icon. You will see your app starting with a delay, which is not a desired UX.
Blank, black or white screen, it really depends on the android:windowBackground
attribute specified in your main activity theme.
The best you can do, apart from moving some of the initialisations that you probably are doing in your Application.onCreate
method, is to brand your preview window with a logo as suggested in this post:
https://plus.google.com/+AndroidDevelopers/posts/Z1Wwainpjhd
You can go further and improve the user experience by animating your logo image in a splash screen, if it's the case, or by designing the preview window in a way that can be smooth transitioned to your main activity content, like described here:
http://saulmm.github.io/avoding-android-cold-starts
Same question is answered correctly here: https://stackoverflow.com/a/40482549/7094200 and described in this blog post: https://www.bignerdranch.com/blog/splash-screens-the-right-way/
The problem you are facing here is called 'cold start' and it's the time mostly spent in your Application.onCreate
method, which usually does some initialisations and it might take longer than you wish. You can read here the official documentation: https://developer.android.com/topic/performance/launch-time.html
If this is the case than setting the theme to translucent or disabling preview as others suggested will only apparently solve the issue, because in reality you will try to launch the app and you won't receive any feedback about the fact the you tapped the app icon. You will see your app starting with a delay, which is not a desired UX.
Blank, black or white screen, it really depends on the android:windowBackground
attribute specified in your main activity theme.
The best you can do, apart from moving some of the initialisations that you probably are doing in your Application.onCreate
method, is to brand your preview window with a logo as suggested in this post:
https://plus.google.com/+AndroidDevelopers/posts/Z1Wwainpjhd
You can go further and improve the user experience by animating your logo image in a splash screen, if it's the case, or by designing the preview window in a way that can be smooth transitioned to your main activity content, like described here:
http://saulmm.github.io/avoding-android-cold-starts
Same question is answered correctly here: https://stackoverflow.com/a/40482549/7094200 and described in this blog post: https://www.bignerdranch.com/blog/splash-screens-the-right-way/
edited May 23 '17 at 12:18
Community♦
11
11
answered Nov 20 '16 at 10:42
raducotiraducoti
11924
11924
add a comment |
add a comment |
Really! the below link work for me!!!!
https://cyrilmottier.com/2013/01/23/android-app-launching-made-gorgeous/
write the separate style in style.xml for your splash screen so that you can co-relate both the screen.
Herein the style:
<style name="AppTheme.Splash" parent="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/splash_final</item>
</style>
add a comment |
Really! the below link work for me!!!!
https://cyrilmottier.com/2013/01/23/android-app-launching-made-gorgeous/
write the separate style in style.xml for your splash screen so that you can co-relate both the screen.
Herein the style:
<style name="AppTheme.Splash" parent="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/splash_final</item>
</style>
add a comment |
Really! the below link work for me!!!!
https://cyrilmottier.com/2013/01/23/android-app-launching-made-gorgeous/
write the separate style in style.xml for your splash screen so that you can co-relate both the screen.
Herein the style:
<style name="AppTheme.Splash" parent="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/splash_final</item>
</style>
Really! the below link work for me!!!!
https://cyrilmottier.com/2013/01/23/android-app-launching-made-gorgeous/
write the separate style in style.xml for your splash screen so that you can co-relate both the screen.
Herein the style:
<style name="AppTheme.Splash" parent="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/splash_final</item>
</style>
answered Apr 22 '17 at 5:34
JoboFiveJoboFive
39967
39967
add a comment |
add a comment |
It' s android features. You can change background color of your blankscreen. Use style:
<resources>
<style name="Theme" parent="android:style/Theme" />
<style name="Theme.MainTheme" parent="Theme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@drawable/background_drawable</item>
</style>
</resources>
then use it in manifest:
<application
android:name="@string/app_name"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.MainTheme"
>
add a comment |
It' s android features. You can change background color of your blankscreen. Use style:
<resources>
<style name="Theme" parent="android:style/Theme" />
<style name="Theme.MainTheme" parent="Theme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@drawable/background_drawable</item>
</style>
</resources>
then use it in manifest:
<application
android:name="@string/app_name"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.MainTheme"
>
add a comment |
It' s android features. You can change background color of your blankscreen. Use style:
<resources>
<style name="Theme" parent="android:style/Theme" />
<style name="Theme.MainTheme" parent="Theme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@drawable/background_drawable</item>
</style>
</resources>
then use it in manifest:
<application
android:name="@string/app_name"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.MainTheme"
>
It' s android features. You can change background color of your blankscreen. Use style:
<resources>
<style name="Theme" parent="android:style/Theme" />
<style name="Theme.MainTheme" parent="Theme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@drawable/background_drawable</item>
</style>
</resources>
then use it in manifest:
<application
android:name="@string/app_name"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.MainTheme"
>
answered May 20 '15 at 7:31
Android AndroidAndroid Android
6151719
6151719
add a comment |
add a comment |
I fixed mine by just updating the build tools in Android Studio.
add a comment |
I fixed mine by just updating the build tools in Android Studio.
add a comment |
I fixed mine by just updating the build tools in Android Studio.
I fixed mine by just updating the build tools in Android Studio.
answered Aug 9 '18 at 19:55
BrentBrent
1,40411014
1,40411014
add a comment |
add a comment |
I think this is similar to some answers that have been posted above. I still would like to recommend the following Big Nerd Ranch guide on how to create a splash screen the right way because its well illustrated and easy to follow. You should really go there and read it instead of continuing below :).
https://www.bignerdranch.com/blog/splash-screens-the-right-way/
But in short what it suggests is, at app start you launch an initial splash activity. For this activity you create an XML drawable (@drawable/background_splash
).
<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>
Then you create a theme for splash activity’s and set the drawable you created above as its window background.
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/background_splash</item>
</style>
And then in the manifest you tell the splash activity to use the above theme.
<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>
Finally in your splash activity implement theonCreate
method like below (thats all the code you need in the activity). This will launch your main activity and finish the splash activity:
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
add a comment |
I think this is similar to some answers that have been posted above. I still would like to recommend the following Big Nerd Ranch guide on how to create a splash screen the right way because its well illustrated and easy to follow. You should really go there and read it instead of continuing below :).
https://www.bignerdranch.com/blog/splash-screens-the-right-way/
But in short what it suggests is, at app start you launch an initial splash activity. For this activity you create an XML drawable (@drawable/background_splash
).
<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>
Then you create a theme for splash activity’s and set the drawable you created above as its window background.
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/background_splash</item>
</style>
And then in the manifest you tell the splash activity to use the above theme.
<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>
Finally in your splash activity implement theonCreate
method like below (thats all the code you need in the activity). This will launch your main activity and finish the splash activity:
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
add a comment |
I think this is similar to some answers that have been posted above. I still would like to recommend the following Big Nerd Ranch guide on how to create a splash screen the right way because its well illustrated and easy to follow. You should really go there and read it instead of continuing below :).
https://www.bignerdranch.com/blog/splash-screens-the-right-way/
But in short what it suggests is, at app start you launch an initial splash activity. For this activity you create an XML drawable (@drawable/background_splash
).
<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>
Then you create a theme for splash activity’s and set the drawable you created above as its window background.
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/background_splash</item>
</style>
And then in the manifest you tell the splash activity to use the above theme.
<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>
Finally in your splash activity implement theonCreate
method like below (thats all the code you need in the activity). This will launch your main activity and finish the splash activity:
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
I think this is similar to some answers that have been posted above. I still would like to recommend the following Big Nerd Ranch guide on how to create a splash screen the right way because its well illustrated and easy to follow. You should really go there and read it instead of continuing below :).
https://www.bignerdranch.com/blog/splash-screens-the-right-way/
But in short what it suggests is, at app start you launch an initial splash activity. For this activity you create an XML drawable (@drawable/background_splash
).
<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>
Then you create a theme for splash activity’s and set the drawable you created above as its window background.
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/background_splash</item>
</style>
And then in the manifest you tell the splash activity to use the above theme.
<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>
Finally in your splash activity implement theonCreate
method like below (thats all the code you need in the activity). This will launch your main activity and finish the splash activity:
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
answered Aug 9 '18 at 21:44
lejonllejonl
1,1381118
1,1381118
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f30342933%2fblank-screen-comes-before-splash%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
possible duplicate of How To fix white screen on app Start up?
– JPS
May 20 '15 at 7:28
1
Why splash screens ? What's so good about a screen in your software that does nothing but make the user wait for your app to start ?
– 2Dee
May 20 '15 at 7:31