Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This gist is used to create an implement launcher screen in Android app. For further details : http://droidmentor.com/create-launch-screen/
<activity
android:name=".SplashActivity"
android:theme="@style/splash_theme"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Splash Screen Background (Color/Image) -->
<item android:drawable="@drawable/ic_background1" />
<!-- App Logo which comes center of the Screen due to gravity:"center" -->
<item>
<bitmap
android:gravity="center"
android:src="@drawable/ic_logo" />
</item>
</layer-list>
public class LauncherActivity extends Activity {
// launcher screen timer
private static int SPLASH_TIME_OUT = 1000;
Handler handler;
Runnable runnable;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
handler = new Handler();
runnable = new Runnable()
{
@Override
public void run()
{
Intent home_activity=new Intent(LauncherActivity.this,HomepageActivity.class);
startActivity(home_activity);
finish();
}
};
handler.postDelayed(runnable, SPLASH_TIME_OUT);
}
@Override
public void onBackPressed() {
super.onBackPressed();
handler.removeCallbacks(runnable);
}
}
<style name="launcher_theme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/launcher_screen</item>
</style>
@Isaac2Ngeno5

This comment has been minimized.

Show comment
Hide comment
@Isaac2Ngeno5

Isaac2Ngeno5 Jul 6, 2018

very helpful .... thanks alot

very helpful .... thanks alot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment