Modify cardview padding

与世无争的帅哥 提交于 2020-01-06 02:43:07

问题


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?

P.S android:layout_marginBottom="-5dp" doesn't seem to work


回答1:


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" />


来源:https://stackoverflow.com/questions/34240078/modify-cardview-padding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!