2016-07-07 79 views
0

Issue:
通過在回收視圖中使用cardview,它將採用頂部和底部的默認邊距。 Issue Image Linkandroid cardview保證金底部默認大於頂部

如何保持兩個相同的保證金?

這裏是我的名片佈局的XML

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/cardcolor" 

    android:orientation="vertical" 
    > 

    <android.support.v7.widget.CardView 
     android:id="@+id/card_view" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_margin="5dp" 
     card_view:cardElevation="0dp" 
     card_view:cardPreventCornerOverlap="false" 
     android:foreground="?android:attr/selectableItemBackground" 
     card_view:cardCornerRadius="2dp" 
     card_view:contentPadding="10dp" 
     card_view:cardUseCompatPadding="false" > 

     ..//body  

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


</LinearLayout> 

我的回收站視圖

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".HomePageActivity"> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/my_recycler_view" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:scrollbars="vertical" 
     layout_marginBottom="5dp" 
     android:background="@color/white"/> 

</RelativeLayout> 
+0

@PiyushGupta我通過網站怎麼回事參考最近添加它。即使去除後仍然沒有效果。 –

+0

只要給5DP的填充在你RecyclerListView然後就看到完整的項目有10dp –

+0

相同的填充也改變的cardview右頁邊距? 。 – Drv

回答

0

在你rowitem做如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:card_view="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:background="@color/cardcolor" 
android:marginTop="2.5dp" 
android:marginBottom="2.5dp" 
android:layout_marginRight="5dp" 
android:layout_marginLeft="5dp" 
android:orientation="vertical"> 

<android.support.v7.widget.CardView 
    android:id="@+id/card_view" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    card_view:cardElevation="0dp" 
    card_view:cardPreventCornerOverlap="false" 
    android:foreground="?android:attr/selectableItemBackground" 
    card_view:cardCornerRadius="2dp" 
    card_view:contentPadding="10dp" 
    card_view:cardUseCompatPadding="false" > 

    ..//body  

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


</LinearLayout> 

並給予距到父佈局的recyclerview :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
layout_marginTop="2.5dp" 
layout_marginBottom="2.5dp" 
tools:context=".HomePageActivity"> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/my_recycler_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:scrollbars="vertical" 
    android:background="@color/white"/> 

    </RelativeLayout> 
+0

不工作:(見http://imgur.com/eZblHen –

+0

抱歉和感謝,但仍佈局,因爲它是我補充保證金底部回收視圖和android:paddingTop =「5DP」 的android:paddingBottom來=「0dp 「在 –

+0

卡的佈局,但一樣的。我希望你不加入任何其他邊距和填充到您的recyclerview和除marginBottom右其父佈局? – Drv

相關問題