Search code examples
androidandroid-studioandroid-cardview

Android Studio CardView is always transparent


I am trying to use Cardview but it somehow doesnt show the background, its always tranparent. I tried to change the background with cardBackgroundColor but it doesnt work, it stays transparent. How can i change the background? enter image description here


Solution

  • I suspect it isnt picking up cardBackgroundColor because you dont have the app namespace. Ensure you have the app namespace in the top container element of your layout

    xmlns:app="http://schemas.android.com/apk/res-auto"