Dawg85
Dawg85

Reputation: 71

Android - View As Splash Screen

I tried to make a splash screen for my app as described here: How do I make a splash screen? This works pretty fine if I use a single image/drawable resource.

But if I create a layout (even with only one image!) as splash screen it won't work; it'll only take longer the app to start and when it opens, it shows the normal layout directly.

Upvotes: 0

Views: 201

Answers (2)

Yessine Mahdouani
Yessine Mahdouani

Reputation: 1264

Try this libraries AwesomeSplash, it provides you many different animation.

compile 'com.github.ViksaaSkool:AwesomeSplash:v1.0.0'

Upvotes: -1

jlively
jlively

Reputation: 743

Since you haven't pasted any code, I don't know if you want help with your code or a suggestion regarding Splash Screens. However, this is the best guide I've seen of how to use Splash screens.

Basically, you create a drawablewith the desired splash screen image.

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

    <item
        android:drawable="@color/white"/>

    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/peem_logo"/>
    </item>

</layer-list>

Next, create a style for your splash activity:

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowBackground">@drawable/splash_drawable</item>
</style>

Make your Activity as Launcher and then in it:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = new Intent(this, MainActivity.class);
    startActivity(intent);
    finish();
}

That's all you need.

Upvotes: 2

Related Questions