2016-05-27 5 views
0

Ich habe ein RecycleView mit einer Karte als Adapter.Nach dem Scrollen füllen meine RecycleView-Karten jeweils einen Bildschirm

RecyvleView in MainActivity:

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

Liste item-Layout mit der Card:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <TextView 
      android:text="TextView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/textView2" 
      android:textAppearance="@style/TextAppearance.AppCompat.Medium" /> 
    </android.support.v7.widget.CardView> 
</LinearLayout> 

Nun das Problem:

Wenn ich die app starten sehe ich alle Elemente: enter image description here

Aber wenn ich scr starten olling jede Karte beginnt einen Bildschirm zu füllen: enter image description here

Was ist hier falsch?

Antwort

2

Listenelement Übergeordnete Layouthöhe und Kartenansichtshöhe ändern sich zu wrap_content anstelle von match_parent. So etwas wie das

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <android.support.v7.widget.CardView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" > 

     <TextView 
      android:text="TextView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/textView2" 
      android:textAppearance="@style/TextAppearance.AppCompat.Medium" /> 
    </android.support.v7.widget.CardView> 
</LinearLayout> 
+0

Vielen Dank jetzt seine Arbeit :) – gurehbgui

+0

Willkommen. Wenn diese Antwort für Sie funktioniert, akzeptieren Sie bitte. – Masum

+0

Natürlich. Warte nur noch 3 Minuten – gurehbgui

Verwandte Themen