4
我正在開發一個圖庫應用程序,在這個應用程序中,我使用圖庫在幻燈片中顯示圖像。它工作正常,但我想添加一些動畫。我只能使用此代碼應用一個動畫,但我想在圖庫視圖中添加兩個動畫效果。 說在翻譯效果,從右到中心和從中心到左側。請任何人幫助我。Android圖庫幻燈片動畫
public void slidShow(){
Runnable runnable = new Runnable() {
@Override
public void run() {
myslideshow();
handler.postDelayed(this, 3000);
}
};
new Thread(runnable).start();
}
private void myslideshow(){
PicPosition = gallery.getSelectedItemPosition() +1;
if (PicPosition >= bitmaps.size()){
PicPosition = gallery.getSelectedItemPosition(); //stop
}
else{
Animation inFromRight = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, +1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
inFromRight.setDuration(500);
inFromRight.setInterpolator(new AccelerateInterpolator());
gallery.startAnimation(inFromRight);
gallery.setSelection(PicPosition);
}
}