0

I have such problem. All my images in recycler view transfering to right side. screenshot This is my adapter

    adapter = new GalleryAdapter(new ArrayList<>(), galleryImage -> galleryLocationPresenter.openGallery(galleryImage), getContext());
    adapter.setHasStableIds(true);
    recyclerView.addItemDecoration(new ListSpacingDecoration(Helpers.dpToPx(15, getContext())));
    staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
    staggeredGridLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_NONE);
    recyclerView.setLayoutManager(staggeredGridLayoutManager);
    recyclerView.setAdapter(adapter);

Here is my row view

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="2dp">

<ImageView
    android:id="@+id/image"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:scaleType="centerCrop" />
</android.support.v7.widget.CardView>

I also tried gap strategy GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS. The same thing.

Igori S
  • 123
  • 8
  • If you know the size of your images, try setting the height in the OnBindViewHolder method. – Dani M Oct 21 '16 at 12:23
  • I dont know the size. Im using picasso to show images `Picasso.with(context).load(galleryImage.getImagePath()).into(image);` – Igori S Oct 21 '16 at 12:26
  • Can't you get the size of the image from galleryImage? It will help you a lot if you set the height of the cardview before drawing it. – Dani M Oct 21 '16 at 12:29
  • Im getting images from internet, `galleryImage.getImagePath()` returns image url – Igori S Oct 21 '16 at 12:33
  • Five years later, have you figured it out? – A_Jayke Feb 06 '22 at 19:23

0 Answers0