Android App için bir Gelişmiş Splash Ekranı

Android programlama ilğili makalelere baktığımızda türkçe kaynaklı makalelerin neredeyse hepsinin “hello world”‘ü tekrar tekrar anlattıklarını gördük ve artık yeni bir “Hello World” yazısı ile sizleri sıkmak istemedik bir adım ilersi olan Android uygulamamıza açılış ekranı yapmak üzerine örnek bir code paylaşmak istedik.

Eclipse’de yeni bir Android proje’si oluşturalım
Project name : AdvancedSplashDemo
Build target: I've set it to Android 2.1
Application name: Advanced Splash Demo
Package name: Advanced Splash Demo
Create Activity: MainActivity – it will be the application itself



public class SplashScreen extends Activity {

/**
* The thread to process splash screen events
*/
private Thread mSplashThread;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Splash screen view
setContentView(R.layout.splash);

final SplashScreen sPlashScreen = this;

// The thread to wait for splash screen events
mSplashThread = new Thread(){
@Override
public void run(){
try {
synchronized(this){
// Wait given period of time or exit on touch
wait(5000);
}
}
catch(InterruptedException ex){
}

finish();

// Run next activity
Intent intent = new Intent();
intent.setClass(sPlashScreen, MainActivity.class);
startActivity(intent);
stop();
}
};

mSplashThread.start();
}

/**
* Processes splash screen touch events
*/
@Override
public boolean onTouchEvent(MotionEvent evt)
{
if(evt.getAction() == MotionEvent.ACTION_DOWN)
{
synchronized(mSplashThread){
mSplashThread.notifyAll();
}
}
return true;
}
}

Appear.xml


Disappear.xml


styles.xml
Theme.Transparent

flag.xml


final ImageView splashImageView = (ImageView) findViewById(R.id.SplashImageView);
splashImageView.setBackgroundResource(R.drawable.flag);
final AnimationDrawable frameAnimation =


(AnimationDrawable)splashImageView.getBackground();


splashImageView.post(new Runnable(){
@Override
public void run() {
frameAnimation.start();
}
});

android-programlama-acilis
/resources

This entry was posted in Android and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *