是)我有的
我有一个GridLayoutManager (RecyclerView)
位置0,2,5,7用自定义图像固定(相对布局转换为位图)& 其余位置填充有服务器图像
我的问题
当我滚动布局中的项目时,它的位置会改变
我的代码
@Override
public void onBindViewHolder(ProfilePhotosViewHolder ProfilePhotosViewHolder, final int position) {
model = list.get(position);
if (position == 0 || position == 2 || position == 5 || position == 7) {
if (position == 0) {
ProfilePhotosViewHolder.relativeBucket.setVisibility(View.VISIBLE);
ProfilePhotosViewHolder.relativeBucket.setDrawingCacheEnabled(true);
ProfilePhotosViewHolder.relativeBucket.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
ProfilePhotosViewHolder.relativeBucket.layout(0, 0, ProfilePhotosViewHolder.relativeBucket.getMeasuredWidth(), ProfilePhotosViewHolder.relativeBucket.getMeasuredHeight());
ProfilePhotosViewHolder.relativeBucket.buildDrawingCache(true);
Bitmap b = Bitmap.createBitmap(ProfilePhotosViewHolder.relativeBucket.getDrawingCache());
ProfilePhotosViewHolder.relativeBucket.setDrawingCacheEnabled(false);
ProfilePhotosViewHolder.imgProfilePhotos.setImageBitmap(b);
}
if (position == 2) {
ProfilePhotosViewHolder.relativeFollowers.setVisibility(View.VISIBLE);
......
}
if (position == 5) {
ProfilePhotosViewHolder.relativeFollowing.setVisibility(View.VISIBLE);
......
}
if (position == 7) {
ProfilePhotosViewHolder.relativePosts.setVisibility(View.VISIBLE);
......
}
} else {
ProfilePhotosViewHolder.relativeBucket.setVisibility(View.GONE);
ProfilePhotosViewHolder.relativeFollowers.setVisibility(View.GONE);
ProfilePhotosViewHolder.relativeFollowing.setVisibility(View.GONE);
ProfilePhotosViewHolder.relativePosts.setVisibility(View.GONE);
ImageLoader imageLoader = AppController.getInstance().getImageLoader();
ProfilePhotosViewHolder.imgProfilePhotos.setImageUrl(model.ImagesUri, imageLoader);
ProfilePhotosViewHolder.imgProfilePhotos.setDefaultImageResId(R.drawable.im_profile_monuments);
ProfilePhotosViewHolder.imgProfilePhotos.setErrorImageResId(R.drawable.im_profile_monuments);
}