carobnodrvo
carobnodrvo

Reputation: 1051

How to create android game loading screen

When you start android app Main activity starts with white background and black header with your app name in left corner. Like this

How to wholly remove this (when app is started not to show this) and add custom loading progress bar or some logo to the screen?

Upvotes: 0

Views: 2182

Answers (3)

carobnodrvo
carobnodrvo

Reputation: 1051

What worked for me (since I don't have much load up on start actually I didn't need splash screen at all) is changing res/values/styles.xml :

<resources>
<color name="custom_theme_color">#000000</color>
<style name="AppTheme" parent="android:Theme.Light" >
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@color/custom_theme_color</item>
</style>
</resources>

It just start with black screen witch goes to full screen (after 1-2 sec) when it is all loaded. It looks very "profesional".

Upvotes: 0

William A Hopkins
William A Hopkins

Reputation: 113

I think what you're looking for can be found here:

how to change the splash screen

Upvotes: 0

vasart
vasart

Reputation: 6702

How about creating a splash dialog with custom layout containing progress bar?

In your main activity do something like this

private SplashDialog mSplashDialog;

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

    showSplashScreen();
    setContentView(R.layout.yourmainlayout);        
}

protected void removeSplashScreen() {
    if (mSplashDialog != null) {
        mSplashDialog.dismiss();
        mSplashDialog = null;
    }
}

protected void showSplashScreen() {
    mSplashDialog = new SplashDialog(this, R.style.splash_dialog);
    mSplashDialog.setCancelable(false);
    mSplashDialog.show();
}

Create custom dialog

public class SplashDialog extends Dialog {
    private ProgressBar mProgressBar;

    public SplashDialog(Context context, int theme) {
        super(context, theme);
        setContentView(R.layout.splash_dialog);
        mProgressBar = (ProgressBar) findViewById(R.id.splash_progress);
    }

    public void setProgress(int progress) {
        mProgressBar.setProgress(progress);
    }
}

And add style to that will let dialog fill all screen.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="splash_dialog">
        <item name="android:padding">0dp</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowFrame">@null</item>
    </style>
</resources>

To change dialog's progress value call mSplashDialog.setProgress(int progress).

When your data is loaded call removeSplashScreen().

Upvotes: 1

Related Questions