0

私が持っているもの

カスタム画像(ビットマップに変換された相対レイアウト)で固定された位置0、2、5、7GridLayoutManager (RecyclerView)を持ち、残りの位置はサーバー画像で満たされています

私の問題

レイアウト内のアイテムをスクロールすると、その位置が変わります

私のコード

@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);
        }

スクリーンショット

スクロール後

4

1 に答える 1