Last active
September 16, 2018 18:50
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style name="launcher_theme" parent="Theme.AppCompat.NoActionBar"> | |
<item name="android:windowBackground">@drawable/launcher_screen</item> | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
very helpful .... thanks alot