我正在使用Glide在ViewPager
上显示一些图片。如您所知,当Glide加载图像时,RGB_565是默认类型。但是,为了显示高质量的图像,我在自定义format()
类的instantiateItem()
方法中使用了ViewPager
Glide方法。
@Override
public Object instantiateItem(ViewGroup container, int position) {
View view = mLayoutInflater.inflate(R.layout.item_viewerlayout, null);
ViewHolder viewHolder = new ViewHolder();
viewHolder.mImageView = (ImageView)view.findViewById(R.id.image_viewerlayout);
viewHolder.mImageViewPlay = (ImageView)view.findViewById(R.id.image_viewerlayoutplay);
viewHolder.mImageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (mGalleryActivity.mMenuLayout.getVisibility() == GONE) mGalleryActivity.openGalleryMenu();
else mGalleryActivity.closeGalleryMenu();
}
});
if (mArrItemType.get(position) == ToolleryMediaDB.TYPE_VIDEO) {
viewHolder.mImageViewPlay.setVisibility(VISIBLE);
viewHolder.mImageViewPlay.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Log.i("CheckLog", "Play Video!");
}
});
}
Glide.with(mContext).load(mArrItemPath.get(position)).asBitmap().format(DecodeFormat.PREFER_ARGB_8888).into(viewHolder.mImageView);
container.addView(view, 0);
return view;
}
而且......这是ViewHolder
类。
public class ViewHolder {
ImageView mImageView;
ImageView mImageViewPlay;
}
尽管调用format(DecodeFormat.PREFER_ARGB_8888)
,ViewPager
上显示的图片仍为RGB_565类型。我不知道为什么。我还需要另外设置吗?