繁体   English   中英

如何定义CardView的边距

[英]How to define margin of 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">

我也想出了同样的问题。 即使我添加了android:layout_marginBottom它也无法正常工作。

但我找到了解决方案。 您的CardView应该在RelativeLayout中。 然后android:layout_marginBottomandroid:layout_marginTop将按预期工作。

如何定义CardView的保证金?

使用属性android:layout_marginLeftandroid:layout_marginRightandroid:layout_marginTopandroid:layout_marginBottom来定义CardView边距。

支持CardView的默认保证金是多少?

这是CardView 文档 另请参阅设计指南

仅供参考,使用属性card_view:cardUseCompatPadding="false"删除CardView内部的内部padding

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM