RECYCLERVIEW SPACE BETWEEN ITEMS ON ANDROID APPLICATION -


i have project developing have come face problem large gap appearing between 2 items on android application ,i had tried on every previous suggestions here on how solve problem none has worked me

here layout causes problems

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_gravity="center" android:gravity="center" android:layout_height="match_parent" android:orientation="horizontal">  <android.support.v7.widget.recyclerview     android:id="@+id/prodct_list"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_alignparenttop="false"     android:scaletype="fitxy"     android:padding="0dp"     android:adjustviewbounds="true"/>  <android.support.design.widget.floatingactionbutton android:id="@+id/actionbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_alignparentend="true" android:layout_alignparentright="true" android:layout_gravity="end" android:visibility="gone" /> 

and here oncreate method on activity associated above layout:

@override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);      tabletsize = getresources().getboolean(r.bool.istablet);     if (!tabletsize) {         setrequestedorientation(activityinfo.screen_orientation_portrait);     }     setcontentview(r.layout.order_details);      ab = getsupportactionbar();     ab.setdisplayuselogoenabled(true);     ab.setdisplayhomeasupenabled(true);      actionbutton = (floatingactionbutton) findviewbyid(r.id.actionbutton);     actionbutton.setbackgroundcolor(getresources().getcolor(r.color.actionbar));     actionbutton.setimageresource(r.drawable.ic_action_send);      apppreference = new apppreference(this);     mrecyclerview = (recyclerview) findviewbyid(r.id.prodct_list);     mrecyclerview.sethasfixedsize(true);     mrecyclerview.setitemanimator(new defaultitemanimator());      mlayoutmanager = new linearlayoutmanager(this);     mrecyclerview.setlayoutmanager(mlayoutmanager);      final intent intent = getintent();     pyid = intent.getextras().getlong(quotes.id);      mitemsdetail = quoteitems.getitemsarray(this ,pyid);      madapter = new deliverydetailsadapter(this, mitemsdetail);     mrecyclerview.setadapter(madapter);      pcontent = new parsecontent(this);     title = intent.getextras().getstring(quotes.reference);     if (pyid == 0)         finish();      if (validating.areset(title))         ab.settitle("quote details");     else         ab.settitle(getstring(r.string.strorder));      mrecyclerview.addonitemtouchlistener(             new recyleritemclick(this, new recyleritemclick.onitemclicklistener() {                 @override                 public void onitemclick(view view, int position) {                  }             })     ); 

and here list of items populated on recyclerview:

<android.support.v7.widget.cardview xmlns:card_view="http://schemas.android.com/apk/res-auto"     android:id="@+id/card_view11"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:layout_above="@+id/rltotals"     android:layout_below="@+id/autotxtsaleclientname"     card_view:cardbackgroundcolor="@color/white"     card_view:cardcornerradius="7.0dip"     card_view:cardelevation="0dp">      <android.support.v7.widget.recyclerview         android:id="@+id/prodct_list"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_alignparenttop="true"         android:scrollbars="vertical" /> </android.support.v7.widget.cardview> 

and when run application on part items on recyclerview displays large gap between each item can me solve issue gap between items

the problem adapter class. need make adapter class parent height wrap_content. since recylerview vertical, need change height of adapter parent layout wrap_content. after if problem exists check whether other adapter child view height match_parent, if change wrap_content.

hope helpful :)


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -