我正在使用 PagerAdapter 来翻阅图片,当我到达集合的末端并尝试进一步翻转时,我的视图右侧出现蓝色渐变。当我回到起点并尝试再向左翻转一个时,左侧出现蓝色模糊。
有任何想法吗?这是我的 PagerAdapter 代码:
public class PictureFlipperAdapter extends PagerAdapter {
Context context;
String[] images;
MediaHelper mh;
public PictureFlipperAdapter(Context context,String[] images){
this.context=context;
this.images=images;
mh=MediaHelper.getInstance(context);
for (String img : images) Log.v("Image",img);
}
@Override
public int getCount() {
return images.length;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == ((ImageView) object);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
ImageView imageView = new ImageView(context);
int padding = context.getResources().getDimensionPixelSize(R.dimen.padding_medium);
imageView.setPadding(padding, padding, padding, padding);
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
//Resize the image to just fit the window and return it
Bitmap resizedImg=BitmapFactory.decodeFile(images[position]);
//Log.v("image size",resizedImg.getByteCount()+"");
imageView.setImageBitmap(resizedImg);
((ViewPager) container).addView(imageView, 0);
return imageView;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
((ViewPager) container).removeView((ImageView) object);
}
}