Skip to content

Instantly share code, notes, and snippets.

@jaisonfdo
Last active September 16, 2018 18:50
Show Gist options
  • Save jaisonfdo/2551041a50383dd3c68567fc97bcdfac to your computer and use it in GitHub Desktop.
Save jaisonfdo/2551041a50383dd3c68567fc97bcdfac to your computer and use it in GitHub Desktop.
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
Copy link

very helpful .... thanks alot

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