Splashscreen.java
import android.app.Activity; import android.content.Intent; import android.graphics.PixelFormat; import android.os.Bundle; import android.view.Window; import android.view.WindowManager; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ImageView; import android.widget.LinearLayout; public class Splashscreen extends Activity { public void onAttachedToWindow() { super.onAttachedToWindow(); Window window = getWindow(); window.setFormat(PixelFormat.RGBA_8888); } /** Called when the activity is first created. */ Thread splashTread; @Override public void onCreate(Bundle savedInstanceState) { this.requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); super.onCreate(savedInstanceState); setContentView(R.layout.splashscreen); StartAnimations(); } private void StartAnimations() { Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha); anim.reset(); LinearLayout l=(LinearLayout) findViewById(R.id.lin_lay); l.clearAnimation(); l.startAnimation(anim); anim = AnimationUtils.loadAnimation(this, R.anim.translate); anim.reset(); ImageView iv = (ImageView) findViewById(R.id.splash); iv.clearAnimation(); iv.startAnimation(anim); splashTread = new Thread() { @Override public void run() { try { sleep(2500); Intent intent = new Intent(Splashscreen.this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); Splashscreen.this.finish(); } catch (InterruptedException e) { // do nothing } finally { Splashscreen.this.finish(); } } }; splashTread.start(); } }
alpha
<?xml version="1.0" encoding="utf-8"?>
<alpha
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="3000" />
translate
<xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
<translate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0%"
android:toXDelta="0%"
android:fromYDelta="200%"
android:toYDelta="0%"
android:duration="2000"
android:zAdjustment="top" />
</set>
Tidak ada komentar:
Posting Komentar