Skip to content
Advertisement

How can i remove unnecessary top padding in cardview?

I managed to implement Cardviews in my app, but the cardview show an unnecessary padding in the top.

enter image description here

What i want to achieve is to get a header image like this :

enter image description here

Here’s my cardview Layout file :

JavaScript

This is the code of the RecyclerView :

JavaScript

android:layout_height=”match_parent” android:padding=”16dp”>

JavaScript

I manage to change the attribute cardUseCompatPadding but that not affect the internal form of the cardview, it’s just there to separate them.

Thanks in advance.

Advertisement

Answer

I found a solution for my problem by changing the height of the imageView to 130dp. Apparently since i made the with of the image to match_parent, i had to find the exact height that will suit the image inside the cardview without giving it some extra padding.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement