0

When I scroll up my recyclerview using match_parent in the imageview everytime it has an image the scroll bar will automatically jump upper to the previous item.

The same happens when I define a width to the image (400dp) - smaller than it, no problem happens.

any ideas why my recyclerview jump up when it has and image with match_parent?

carview

<android.support.v7.widget.CardView
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

 <LinearLayout
            android:padding="@dimen/activity_horizontal_margin"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

  <com.android.volley.toolbox.NetworkImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="0dp"
                android:id="@+id/imageViewHero"
                android:adjustViewBounds="true" />...

recyclerview

  <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentStart="true"
        android:layout_alignParentLeft="true" />

oncreateviewholder

  @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.posts_list, parent, false);
        ViewHolder viewHolder = new ViewHolder(v);
        return viewHolder;
    }
@Override
public void onBindViewHolder(ViewHolder holder, int position) {

    Posts post =  Posts.get(position);
    holder.post = post;

    //Loading image from url
    imageLoader = CustomVolleyRequest.getInstance(context).getImageLoader();

    //Showing data on the views
    holder.imageView.setImageUrl(post.getImageUrl(), imageLoader);
    holder.textViewName.setText(post.getName());
    holder.textViewPublisher.setText(post.getPublisher());

    holder.setIsRecyclable(false);

}
RGS
  • 4,062
  • 4
  • 31
  • 67
  • Can you share your code for `onCreateViewHolder` - specifically, the call to create the `View`? – Cheticamp Feb 28 '17 at 15:01
  • hi @Cheticamp my onCreateViewHolder? I added it to my post. not sure if it is what you want. if not, please, tell me! – RGS Feb 28 '17 at 15:06
  • 1
    Try changing the second argument of `inflate` to `null` to see if that corrects the problem. The second argument is used to define layout parameters - see the [documentation](https://developer.android.com/reference/android/view/LayoutInflater.html#inflate(int,%20android.view.ViewGroup,%20boolean)). If that works, you can set the layout parameters separately. – Cheticamp Feb 28 '17 at 15:29

1 Answers1

2

I believe that you are having an issue with changes to how RecyclerView layouts are handled starting with revision 23.2.0.

See the answer from Sevle here that references revision 23.2.0 changes to RecyclerView here.

For a fuller explanation, see this posting.

It's all very confusing, but I hope this helps.

Community
  • 1
  • 1
Cheticamp
  • 61,413
  • 10
  • 78
  • 131