修改cardview内边距 [英] Modify cardview padding

查看:245
本文介绍了修改cardview内边距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要使卡片高程可见,我在卡片视图XML中使用属性card_view:cardUseCompatPadding="true".它在cardview的所有四个侧面上都添加了额外的填充,但是我不需要底部填充,因为每张卡下面的卡已经具有顶部填充了.因此,由于顶部+底部填充,当前就像两张卡之间的两次填充.如何减少一半?

For card elevation to be visible, I use the attribute card_view:cardUseCompatPadding="true" in cardview XML. It added extra padding on all four sides of the cardview, but I do not need the bottom padding since the card below every card will already have a top padding. So currently it is like double padding between two cards because of top+bottom padding. How to reduce it by half?

PS android:layout_marginBottom="-5dp"似乎不起作用

推荐答案

仅在卡片的底部使用边距,并在装有卡片的RecyclerView/ListView的顶部设置填充:

Only use a margin at the bottom for the cards and set a padding to the top of your RecyclerView/ListView holding the cards:

<android.support.v7.widget.RecyclerView
    ...
    android:paddingTop="5dp"
    android:clipToPadding="false" />

这篇关于修改cardview内边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆