android ImageSwitcher的使用

来源:互联网 发布:数据分析师招聘信息 编辑:程序博客网 时间:2024/06/11 21:07
ImageSwitcher   is = (ImageSwitcher) findViewById(R.id. is );
          //设置图片动画
            is.setInAnimation(AnimationUtils. loadAnimation( this, R.anim.in ));
            is.setOutAnimation(AnimationUtils. loadAnimation( this, R.anim.out ));
            is.setFactory( new ViewFactory() {
                 @Override
                 public View makeView() {
                     ImageView iv = new ImageView(MainActivity.this );
                     iv.setBackgroundColor(Color. RED);
                     iv.setScaleType(ScaleType. FIT_CENTER);
                     iv.setLayoutParams( new ImageSwitcher.LayoutParams(
                                ImageSwitcher.LayoutParams. WRAP_CONTENT,
                                ImageSwitcher.LayoutParams. WRAP_CONTENT));
                      return iv;
                }
           });

通过     is.setImageResource(图片资源id);设置显示的图片
0 0