2

Ich habe und App mit CardView gemacht, aber mein cardview geht in eine Karte.Cardview ist alles in einer Karte

Mein Code:

recyclerview_activity.xml:

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

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

    </android.support.v7.widget.RecyclerView> 


</LinearLayout> 

I get something like this

+1

Bitte kopieren Sie Ihre item.xml hier und auch den Screenshot von dem, was Sie mit Ihrem Code bekommen – Manishika

+0

@manishika, hinzugefügt –

+0

Dies ist kein Forum. Sie "lösen" Beiträge, indem Sie Antworten akzeptieren. –

Antwort

1

denke ich, das einzige Problem mit der Lücke zwischen Ihrem CardViews ist. Sie müssen CompatPadding true in CardView nicht haben, deshalb sieht es so aus, als ob die Daten in einem CardView clubbed sind, versuchen Sie, es wahr zu machen. Verwenden folgenden Code sollte es funktionieren:

<?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:id="@+id/cv" 
    card_view:cardCornerRadius="5dp" 
    card_view:cardUseCompatPadding="true" 
    android:foreground="?android:attr/selectableItemBackground" 
> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:padding="16dp" 
    > 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/person_photo" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginRight="16dp" 
     /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/person_name" 
     android:layout_toRightOf="@+id/person_photo" 
     android:layout_alignParentTop="true" 
     android:textSize="30sp" 
     /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/person_age" 
     android:layout_toRightOf="@+id/person_photo" 
     android:layout_below="@+id/person_name" 
     /> 

</RelativeLayout> 

</android.support.v7.widget.CardView> 
+0

Was meinst du mit der Rückgabe der Aktionsleiste? Ihre Frage hatte keinen Aktionsleistenpunkt. Was genau ist das Problem mit der Aktionsleiste? Ich habe Ihre Frage für das Cardview-Problem beantwortet und ich denke, das funktioniert jetzt. Recht? – Manishika

+1

Sie können Hilfe von hier http://www.vogella.com/tutorials/AndroidActionBar/article.html nehmen. Wenn meine Antwort für Ihr Kartenansichtproblem korrekt ist, markieren Sie sie als Antwort. Vielen Dank – Manishika