有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何定义CardView的页边距

支持CardView的默认保证金是多少,以便我可以根据自己的情况定义保证金

<安卓.support.v7.widget.CardView xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
    xmlns:card_view="http://schemas.安卓.com/apk/res-auto"
    xmlns:tools="http://schemas.安卓.com/tools"
    安卓:layout_width="wrap_content"
    安卓:layout_height="match_parent"
    安卓:layout_gravity="center_horizontal"
    card_view:cardUseCompatPadding="true"
    card_view:cardCornerRadius="4dp"
    card_view:cardElevation="2dp">

共 (2) 个答案

  1. # 1 楼答案

    我也提出了同样的问题。即使我添加了android:layout_marginBottom,它也不起作用

    但我找到了解决办法。 您的CardView应该位于RelativeLayout内。然后android:layout_marginBottomandroid:layout_marginTop将按预期工作

  2. # 2 楼答案

    如何定义CardView的边距

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

    CardView的默认支持边际是多少

    这里是CardView{a1}。另见Design Guidelines

    FYI,使用属性card_view:cardUseCompatPadding="false"删除CardView内的内部padding