Search code examples
androidxmlandroid-studioandroid-cardview

How to remove cardview padding?


I'm developing an android app and I have a cardview on my xml to make the pictures circular. Although I could change the color of the cardview itself, I'm having a hard time removing the strange dark padding that comes with it: strange padding

My code is below:

<androidx.cardview.widget.CardView
        android:id="@+id/profilePictureCircle"
        android:layout_width="260dp"
        android:layout_height="260dp"
        app:cardPreventCornerOverlap="false"
        app:cardUseCompatPadding="false"
        app:cardBackgroundColor="@color/colorBottomNavigationApp"
        android:layout_alignParentTop="true"
        android:layout_marginTop="30dp"
        android:layout_toStartOf="@+id/profileName"
        android:layout_toLeftOf="@+id/profileName"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <ImageView
            android:id="@+id/chosen_picture"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:srcCompat="@drawable/camera" />
</androidx.cardview.widget.CardView>

I've tried several things and none seemed to work. Can anyone help please? Thanks!


Solution

  • The answer is that cardElevation should be set to 0