2016-05-24 13 views
1

Ich verwende eine RecyclerView als Kind eines anderen RecyclerView, aber wenn ich Daten zu zweiten RecyclerView hinzufügen zeigt es nichts. Ich sollte sagen, wenn ich die Höhe der Sekunde RecyclerView auf (z. B. 100dp) setze zeigt es einige Inhalte davon.RecylerView Höhe nicht gefüllt, wenn in einem anderen RecyclerView

Wie soll ich das Problem lösen?

-main xml

<android.support.v7.widget.RecyclerView 
     android:id="@+id/recycler_view1" 
     android:layout_margin="@dimen/activity_horizontal_margin" 

     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 

    <ProgressBar 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/progressBar3" 
     android:visibility="gone" 
     android:background="#1E88E5" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" /> 

</RelativeLayout> 
  • Artikel xml

    <RelativeLayout 
        android:clickable="true" 
        android:id="@+id/lla2" 
        android:layout_width="match_parent" android:layout_height="match_parent"> 
    
        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:textAppearance="?android:attr/textAppearanceLarge" 
         android:text="Medium Text" 
         android:id="@+id/textView3" 
         android:layout_alignParentTop="true" 
         android:layout_marginTop="@dimen/activity_horizontal_margin" 
         android:layout_marginBottom="@dimen/activity_horizontal_margin" 
         android:layout_alignRight="@+id/view13" 
         android:layout_alignEnd="@+id/view13" 
         android:layout_toEndOf="@+id/ib2" 
         android:layout_alignLeft="@+id/view13" 
         android:layout_alignStart="@+id/view13" 
         android:layout_toRightOf="@+id/ib2" /> 
    
        <View 
         android:layout_width="match_parent" 
         android:layout_height="1dp" 
         android:background="@android:color/darker_gray" 
         android:id="@+id/view13" 
         android:layout_margin="@dimen/activity_horizontal_margin" 
         android:layout_below="@+id/textView3" 
         android:layout_toRightOf="@+id/ib2" 
         android:layout_toEndOf="@+id/ib2" /> 
    
        <android.support.v7.widget.RecyclerView 
         android:id="@+id/recycler_view6" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginRight="@dimen/activity_horizontal_margin" 
         android:layout_marginEnd="@dimen/activity_horizontal_margin" 
         android:layout_marginBottom="@dimen/activity_horizontal_margin" 
         android:layout_alignLeft="@+id/textView3" 
         android:layout_alignStart="@+id/textView3" 
         android:layout_below="@+id/view13" /> 
    
    
        <ImageButton 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:background="?selectableItemBackground" 
         android:src="@drawable/ic_more_vert_black_24dp" 
         android:alpha="0.5" 
         android:id="@+id/ib2" 
         android:layout_marginTop="@dimen/activity_horizontal_margin" 
         android:layout_alignTop="@+id/textView3" 
         android:layout_alignParentLeft="true" 
         android:layout_alignParentStart="true" /> 
    
        <ImageButton 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:background="?selectableItemBackground" 
         android:src="@drawable/note" 
         android:layout_marginTop="@dimen/activity_horizontal_margin" 
         android:id="@+id/imageButton" 
         android:alpha="0.1" 
         android:layout_below="@+id/ib2" 
         android:layout_alignParentLeft="true" 
         android:layout_alignParentStart="true" /> 
    
        <ImageButton 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:background="?selectableItemBackground" 
         android:src="@drawable/bookmark" 
         android:alpha="0.5" 
         android:id="@+id/imageButton2" 
         android:layout_below="@+id/imageButton" 
         android:layout_alignParentLeft="true" 
         android:layout_alignParentStart="true" /> 
    
    
    </RelativeLayout> 
    

+0

bitte posten Sie die XML. –

+0

@LucasPaolillo Ich postete xml – Ali

Antwort

0

Sind Sie Verwenden eines LinearLayout-Managers? Wenn ja, ist das dein Problem. Es war nicht so gut, die Höhe mit wrap_content bis vor kurzem zu messen. Wenn Sie eine relativ neue Version der recyclerview Bibliothek verwenden (und einen LinearLayoutManager verwenden), um einen Anruf zu dieser machen:

yourLinearLayoutManager.setAutoMeasureEnabled(true);

Das Auto Maßnahme ermöglichen wird, und führen Sie es mit wrap_content zu arbeiten. Da dies eine verschachtelte Recycleransicht ist, sollten Sie auch das verschachtelte Scrollen vergessen.

+0

Ich verwende GridLayoutManager gridLayoutManager = new GridLayoutManager (Kontext, items.get (0) .getTranslate(). Size()> 1? 2: 1); – Ali

+0

GridLayoutManager verfügt auch über die Opt-in-API autoMesure. Ich würde das im Layout-Manager Ihres verschachtelten Recyclerview aufrufen und sehen, ob das Ihr Problem behebt. Genannt wie in meiner ersten Antwort. – craya

+0

Ich habe getestet, aber nichts ist passiert. – Ali

Verwandte Themen