the CardView ( android.support.v7.cardview ) stays white even though I set a backround drawable via android:backround - The documentation gives me the feeling that it should work. No Idea what I am doing wrong here.
Make Cardview will host one viewgroup for eg relative layout in this case and then simply set any background to relative layout. Show activity on this post. I got this working by adding a linearlayout in the cardview and then setting cardPreventCornerOverlap to false in the cardview. Show activity on this post.
card_view:cardBackgroundColor="@android:color/white" check with this.
try setting cardview height to wrap content and set the text view height to 44dp. You can also add a LinearLayout to the cardView, set the height and width to match parent, set the gradient background, then add the textview inside the LinearLayout.
I know this is an old question, but I have a simple solution - just make the first child of your CardView an ImageView and specify the scale type to fitXY. You can get rid of the extra CardView padding by setting cardElevation and cardMaxElevation to 0dp
:
<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="200dp" app:cardCornerRadius="4dp" app:cardElevation="0dp" app:cardMaxElevation="0dp"> <ImageView android:src="@drawable/your_background" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="fitXY"/> <... your layout .../> </android.support.v7.widget.CardView>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With