rishie
rishie

Reputation: 77

How to remove white screen before loading of first activity in android?

Whenever i launch my app, a white screen appears in the beginning with the title bar. I don't want this screen to be appear in my app. I have read previous questions, but answers are not clear to me.

I'm also using splash screen, but white screen appears before that.

I don't want to change the theme style, because it either increases the minimum sdkVersion or changes the style of edittext, buttons, checkboxes etc

Please help me to keep me out of this.

Thank you.

Upvotes: 4

Views: 5938

Answers (4)

Sarthak Dhami
Sarthak Dhami

Reputation: 330

Add below line in your Theme of splash screen as you wrote you are using splash screen

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


Upvotes: 0

Wooz12345
Wooz12345

Reputation: 179

1- Make windowDisablePreview false in your style.xml

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

2- Add windowBackground in your style.xml.

<item name="android:windowBackground">@drawable/your_background</item>

Upvotes: -1

Anukool srivastav
Anukool srivastav

Reputation: 797

If you are using AppCompatActivity then create below theme in style.xml :

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

And in manifest file for SplashActivity add theme :

android:theme="@style/Theme.Transparent"

Upvotes: 0

RocketSpock
RocketSpock

Reputation: 2081

Preface: For questions like this you should post your starting activities xml and the onCreate() and associated methods.

When android starts your application it will typically use a black view to indicate that it is launching, this my change to white with your theme/style selected. If you are loading the view correctly then you should only see this blank (white or black) page for 50-200 ms (I can't find the google document for this right now). If you are doing a lot of work in your onCreate method then it will take longer.

Typically to make my views display faster I will simply do the majority of the linking work after it has loaded. ex:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.initial_activity_layout);

    //We use a handler so that the activity starts very fast
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            delayedInit();
        }
    }, 100);
}

Additionally, mobile applications should typically not have a splash screen unless they take quite a while to load the contents (e.g. games, first time launch files, etc.) and should not be used just to brand your application, or display your company name.

Update (July 31, 2015)

Google apps are now moving in the direction of having splash screens (see drive, GMail, etc.)

Additionally, You shouldn't be doing any work other than de-referencing views in the onCreate() method. Any long running operations such as retrieving information from memory (database, prefs, etc.) should be done in an AsyncTaskLoader or AsyncTask.

Upvotes: 3

Related Questions