2017-10-18 1 views
0

Hallo i ont un problème à l'intérieur gridviiew recyclerview, il y a quelques espaces au-dessus de la grille 2. élément comme ce pic. que les espaces changent dinamicaly si je recharge le contenu à l'intérieur de recyclerview.espaces supplémentaires à l'intérieur gridview recyclerview

recyclerview normale

<android.support.v7.widget.RecyclerView 
        android:id="@+id/recyclerView2" 
        android:layout_width="match_parent" 

        android:layout_height="match_parent" 
        /> 

article Vignettes

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.CardView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 

    android:layout_margin="2dp" 

    android:clickable="true" 
    android:clipChildren="true" 


    card_view:cardPreventCornerOverlap="false" 
    card_view:cardUseCompatPadding="false" 
    android:foreground="?attr/selectableItemBackground" 
    android:orientation="vertical"> 

enter image description here

+0

où est xml ???? –

+0

xml ajouté @IntelliJAmiya Amiya – Muklas

Répondre

0

trouvé une solution bizarre par ajouter 2 contenu factice et retirez-le (point 1 et 2) dans adaptateur recycleur onBindViewHolder résolu mon problème.

if (position == 1 || position == 0) { 
//    holder; 
       LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
         0, 
         0 
       ); 
       int margin = dpToPx(0); 
       params.setMargins(margin, margin, margin, margin); 
       holder.cardview2.setLayoutParams(params); 
       holder.cardview2.setVisibility(View.GONE); 


      } else { 

alors quel est le problème?