我正在嘗試設置不同圖像的自定義動畫幻燈片。我管理使用自定義視圖爲單個圖像設置動畫。現在我想爲我的數組列表中的所有圖像設置幻燈片放映。因此,圖像將在彼此之後顯示。現在我有一個自定義視圖,我需要爲每個圖像製作更多視圖嗎?有任何想法嗎?使用android中的圖像創建動畫序列(SlideShow)
自定義視圖:
public class AnimationPhotoViewA extends ImageView { @Overridepublic void setImageBitmap(Bitmap bm) {super.setImageBitmap(bm);image= bm;}
活動:
public class PhotoSyncActivity extends Activity implements AnimationListener {
@Override
protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);
setContentView(R.layout.photo_sync_screen);
ArrayList<String> photoPaths = new ArrayList<String>();
photoPaths = getAllPhotos(Environment.getExternalStorageDirectory(),
photoPaths);
images = new Bitmap[photoPaths.size()];
Log.v(ACCESSIBILITY_SERVICE, "photo array!" + photoPaths);
apa1 = (AnimationPhotoViewA) findViewById(R.id.animation_viewA);
//START ANIMATION
animationmove = PhotoAnimationProcess.moveOne(this,apa1,animationmove);
File imgFile = new File(photoPaths.get(0));
if (imgFile.exists())
{
images[0] = decodeFile(imgFile);
}
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
// SET IMAGE IN THE VIEW
apa1.setImageBitmap(resizedimage);
}
private void addPicture() {
// TODO Auto-generated method stub
}
public void onAnimationStart(Animation animation)
{
// TODO Auto-generated method stub
}
public void onAnimationEnd(Animation animation)
{
// TODO Auto-generated method stub
switch (animationmove)
{
case move1:
animationmove = PhotoAnimationProcess.moveOne(this, apa1, animationmove);
break;
case move2:
addPicture();
animationmove = PhotoAnimationProcess.moveTwo(this,apa1,animationmove);
break;
case move3:
animationmove = PhotoAnimationProcess.moveThree(this,apa1,animationmove);
break;
case move4:
animationmove = PhotoAnimationProcess.moveFour(this,apa1,animationmove);;
break;
case move5:
animationmove = PhotoAnimationProcess.moveFive(this,apa1,animationmove);
break;
default:
break;
}
Log.v(ALARM_SERVICE, "Animation Type" + animation.toString());
}
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
}
感謝:您既可以添加爲ApiDemos所示的ViewFactory或者只是添加在佈局文件,這些圖像的看法!我需要這些圖像以專門的動畫在語法上運行,而不關注某個圖像。我不認爲ImageSwitcher會幫助我 – user182192 2012-04-08 11:48:08
你誤解了Darth Beleg的答案。 ImageSwitcher(或者其他任何切換器)讓您可以輕鬆訪問動畫,以便很好地交換圖像。你可以用你想要的任何Bitmaps以編程方式填充這些圖像,並節省自己重新發明這個輪子的麻煩(這就是你上面做的)。 – 2012-04-18 15:50:29