I managed to implement Cardviews in my app, but the cardview show an unnecessary padding in the top.
What i want to achieve is to get a header image like this :
Here’s my cardview Layout file :
<android.support.v7.widget.CardView
android:id="@+id/programCardview"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
card_view:cardUseCompatPadding="true"
xmlns:card_view="http://schemas.android.com/apk/res-auto">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <ImageView
        android:id="@+id/programHeader"
        android:layout_width="match_parent"
        android:layout_height="160dp"
        android:src="@drawable/createdprogramviewcard"/>
    <RelativeLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:paddingBottom="16dp"
        android:paddingLeft="16dp"
        android:paddingRight="16dp">
        <TextView
            android:id="@+id/programTitle"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:text="Programme d'endurance"
            android:textSize="20sp"
            android:textAlignment="center"/>
        <TextView
            android:id="@+id/objectif"
            android:layout_below="@+id/programTitle"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="Objectif : " />
        <TextView
            android:id="@+id/programObjectif"
            android:layout_below="@+id/programTitle"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="6 séances"
            android:layout_toRightOf="@id/objectif"/>
        <TextView
            android:id="@+id/programWorkouts"
            android:layout_below="@+id/programTitle"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:textAlignment="textEnd"
            android:layout_alignParentRight="true"
            android:text="6 séances" />
    </RelativeLayout>
</LinearLayout>
This is the code of the RecyclerView :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height=”match_parent” android:padding=”16dp”>
<android.support.v7.widget.RecyclerView
    android:id="@+id/recyclerViewPrograms"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
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.

