soru:
Sen göğüs ekranına atlama görmek ve güzel animasyon ile sorunsuz açılır? Bir Android uygulamasına nasıl eklenebileceğini bilmek isterim, bu bir çerçeve animasyonu mu?
Çerçeve bir animasyon olduğunu sanmıyorum. Sanırım bu OpenGL kullanılarak uygulandı. Resmi eğitici here bulabilirsiniz.
Basit 2d animasyonlar yapmak istiyorsanız, android tarafından sağlanan AnimationDrawable
api'yi kullanabilirsiniz. Temelde animasyonlar dizilerine yönelik çerçeveleri ve daha sonra size aşağıdaki kodu kullanarak animasyon oluşturabilirsiniz:
// you would need an `ImageView` object as a placeholder for the animation
ImageView mMascotView = findViewById(...);
// prepare the animation object ..
AnimationDrawable mMascotAnimation = new AnimationDrawable();
final int frameTime = 250; // time in milliseconds
// adding the frames to the animation object. You can specify different
// times for each of these in milliseconds
mMascotAnimation.addFrame(getResources().getDrawable(R.drawable.frame1),frameTime);
mMascotAnimation.addFrame(getResources().getDrawable(R.drawable.frame2),frameTime);
mMascotAnimation.addFrame(getResources().getDrawable(R.drawable.frame3),frameTime);
// make it loop infinitely ..
mMascotAnimation.setOneShot(false);
// set the background of the `ImageView` as the `AnimationDrawable`object ..
mMascotView.setBackground(mMascotAnimation);
// start the animation ..
mMascotAnimation.start();
Not: Sen faaliyet onCreate()
yöntemi içinde AnimationDrawable.start()
çağırmamalıdır. Görüşler henüz hazır değil. Geridönüşümü onWindowFocusChanged()
yönteminde kullanmalı ve orada animasyonu başlatın:
@Override
public void onWindowFocusChanged (boolean hasFocus)
{
//Start animation here
if(hasFocus) {
mMascotAnimation.start();
}
}
Teşekkür ederim – Yakirbu