how to create slideshow with imageView?
public class AndroidAnim extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final ImageView imageView1 = (ImageView) findViewById(R.id.ImageView1);
final ImageView imageView2 = (ImageView) findViewById(R.id.ImageView2);
final AnimationDrawable myAnimation1;
i开发者_Python百科mageView1.setBackgroundResource(R.drawable.loadinganim);
imageView2.setBackgroundResource(R.drawable.loadinganim);
myAnimation1 = (AnimationDrawable) imageView1.getBackground();
imageView2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
myAnimation1.start();
imageView2.startAnimation(AnimationUtils.loadAnimation(getBaseContext(), R.anim.effect_in));
}
});
}
}
I am new in android. I need some help. I use this code trying to create slideShow, I want loop images one after another, of course with effect (effect-in.xml in this example). I want to move down imageView1 and after that should move down imageView2, and after that imageView1 and so on. What should I do here, so I get the result, sorry for my english.
You can use the android ViewFlipper which allows to specify a in and out animation for the different views and it will only show 1 view at a time. You set it to flip automatically.
But if you are looking for a continuous slider of a group of images this project might be some reference.
精彩评论