0

I am using TwoWayView

https://github.com/lucasr/twoway-view

its working okey, but sometimes blank space comes to top when scroll to top when load images from server.

My screen xml :

  <package.TwoWayView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/listTwoWay"
    style="@style/TwoWayView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:twowayview_layoutManager="StaggeredGridLayoutManager"
    app:twowayview_numColumns="2"
    app:twowayview_numRows="2" />

My row layout with fix height and width

<?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="300dp"
android:layout_height="300dp"
android:background="@color/color_white_gray">

<ImageView
    android:id="@+id/imgItemGrid"
    android:layout_width="300dp"
    android:layout_height="300dp"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:scaleType="fitXY"
    android:src="@drawable/artist_expand_bg1" />

</RelativeLayout>

and My adapter onbind looks like following

@Override
public void onBindViewHolder(final SimpleViewHolder holder, final int position) {
    final View itemView = holder.itemView;
    //set imageview
    Glide.with(mContext)
            .load(dataList.get(position).getImage())
            .listener(new RequestListener<Drawable>() {
                @Override
                public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                    holder.progressBar.setVisibility(View.GONE);
                    return false;
                }

                @Override
                public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                    holder.progressBar.setVisibility(View.GONE);
                    return false;
                }
            })
            .into(holder.imgItemGrid);

    final int dimenId;
    final int span;

    if (position == 0) {
        dimenId = R.dimen.staggered_child_large;
        span = 2;      
   } else {
        dimenId = R.dimen.staggered_child_large;
        span = 2;
    }
    final int size = mContext.getResources().getDimensionPixelSize(dimenId);
    final StaggeredGridLayoutManager.LayoutParams lp =
            (StaggeredGridLayoutManager.LayoutParams) itemView.getLayoutParams();

    lp.span = span;
    lp.height = size;
    itemView.setLayoutParams(lp);
   }

I have tried programmatically set width of imageview and viewholder, but no luck. Thanks for advance in suggestions or any kind of help.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Shruti
  • 391
  • 1
  • 5
  • 21

1 Answers1

0

finally i have changed to Asymmentric recyclerview library instead. and there is no such issue in this library . Please follow below link.

https://github.com/felipecsl/AsymmetricGridView?utm_source=android-arsenal.com&utm_medium=referral&utm_campaign=1186

Shruti
  • 391
  • 1
  • 5
  • 21