android - Gap between CardViews increases on scrolling -


i'm using carviews recyclerview , looks fine when loaded once when list scrolled gap between cardviews increases , there shows 1 card in view @ time.

here cardview.xml

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     xmlns:app="http://schemas.android.com/apk/res-auto">      <android.support.v7.widget.cardview         android:id="@+id/conversationcard"         android:layout_width="match_parent"         android:layout_height="wrap_content">          <relativelayout             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:padding="16dp">              <textview                 android:id="@+id/sender"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content" />              <textview                 android:id="@+id/abstractconvo"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:textsize="35dp"/>          </relativelayout>      </android.support.v7.widget.cardview>  </linearlayout> 

and here how i'm using view

    public class conversationslistadapter extends recyclerview.adapter<conversationslistadapter.conversationslistviewholder> {      list<conversation> conversationlist;      public conversationslistadapter(list<conversation> conversationlist) {         this.conversationlist = conversationlist;     }      @override     public int getitemcount() {         return conversationlist.size();     }      @override     public conversationslistviewholder oncreateviewholder(viewgroup viewgroup, int viewtype) {         view view = layoutinflater.from(viewgroup.getcontext()).inflate(r.layout.conversation_card, viewgroup, false);         conversationslistviewholder listviewholder = new conversationslistviewholder(view);         return  listviewholder;     }      @override     public void onbindviewholder(conversationslistviewholder holder, int position) {         holder.sender.settext(conversationlist.get(position).getsenderphno());         holder.abstractconvo.settext(conversationlist.get(position).getabstractconvo());     }      public static class conversationslistviewholder extends recyclerview.viewholder {         cardview cv;         textview abstractconvo, sender;          public conversationslistviewholder(view itemview) {             super(itemview);             cv = (cardview) itemview.findviewbyid(r.id.conversationcard);             sender = (textview) itemview.findviewbyid(r.id.sender);             abstractconvo = (textview) itemview.findviewbyid(r.id.abstractconvo);         }     } } 

here screenshot before list scrolled enter image description here

and after scrolling enter image description here

thanks in advance.

the root layout use wrap_content

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto"> 

Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -