Created
June 20, 2014 21:52
-
-
Save FR073N/c3909c1359e67c47041e to your computer and use it in GitHub Desktop.
Android splash 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
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:background="@color/splash" | |
android:orientation="vertical" | |
tools:context=".MainFragment" > | |
<ImageView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_centerInParent="true" | |
android:scaleType="fitCenter" | |
android:adjustViewBounds="true" | |
android:src="@drawable/splash_screen" /> | |
<ProgressBar | |
android:id="@+id/pb_sync" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_alignParentBottom="true" | |
android:layout_centerHorizontal="true" | |
android:background="@drawable/progress_bar" /> | |
</RelativeLayout> |
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="com.sabalicii.sliderpuzzle.ui.extra.SplashActivity" | |
android:theme="@android:style/Theme.NoTitleBar" > | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity> | |
<activity | |
android:name="com.sabalicii.sliderpuzzle.ui.MainActivity" | |
android:label="@string/app_name" > | |
</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
public class SplashActivity extends Activity { | |
public static final int DURATION = 2000; | |
private boolean splashEnded = false; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
this.requestWindowFeature(Window.FEATURE_NO_TITLE); | |
setContentView(R.layout.activity_splash); | |
new Handler().postDelayed(new Runnable() { | |
@Override | |
public void run() { | |
if(!splashEnded){ | |
splashEnded = true; | |
goToMainActivity(); | |
} | |
} | |
}, DURATION); | |
} | |
@Override | |
public boolean dispatchTouchEvent(MotionEvent ev) { | |
//if the splash should stop when touched, uncomment this section | |
/*if(!splashEnded){ | |
goToMainActivity(); | |
}*/ | |
return true; | |
} | |
private void goToMainActivity(){ | |
splashEnded = true; | |
Intent intent = new Intent(SplashActivity.this, HomeActivity.class); | |
startActivity(intent); | |
//overridePendingTransition(0, 0); | |
SplashActivity.this.finish(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment