2

我已经制作并使用CardView的应用程序,但是我的卡片视图将进入一张卡片。Cardview全部进入一张卡片

我的代码:

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

请这里一并复制item.xml你与你的代码 – Manishika

+0

@manishika得到什么的截图,添加 –

+0

这不是一个论坛。您通过接受答案来“解决”帖子。 –

回答

1

我认为唯一的问题是与你的CardViews之间的差距。你不能在CardView上有CompatPadding这就是为什么它看起来像数据clubbed到一个CardView尝试使它成真。 使用下面的代码它应该工作:

<?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

返回行动栏是什么意思!你的问题没有行动栏点。操作栏的问题究竟是什么?我回答你的问题cardview问题,我想现在工作。对? – Manishika

+1

你可以从这里获取帮助http://www.vogella.com/tutorials/AndroidActionBar/article.html。如果我的回答对于你的cardview问题是正确的,那么将其标记为答案。谢谢 – Manishika

相关问题