2017-04-20 26 views
2

支持CardView的默認保證金是多少,所以我可以爲我的情況定義保證金?如何定義CardView的保證金

<android.support.v7.widget.CardView 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="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="center_horizontal" 
    card_view:cardUseCompatPadding="true" 
    card_view:cardCornerRadius="4dp" 
    card_view:cardElevation="2dp"> 

回答

1

如何定義CardView的邊距?

使用屬性android:layout_marginLeftandroid:layout_marginRightandroid:layout_marginTopandroid:layout_marginBottom定義CardView利潤率。

Support CardView的默認邊距是多少?

這裏是CardViewDocumentation。另請參閱Design Guidelines

FYI,使用屬性card_view:cardUseCompatPadding="false"以除去內padding內部CardView

0

我也想出了同樣的問題。即使我添加了android:layout_margin Bottom,它也不起作用。

但我找到了解決方案。 您的CardView應該在RelativeLayout中。然後android:layout_margin Bottom,android:layout_marginTop將按預期工作。