2017-04-20 72 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将按预期工作。