I'm struggling with CardView corner radius and background color with AndroidX libraries.
I've defined my layout as below:
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="@dimen/retail_card_width"
card_view:cardCornerRadius="@dimen/card_radius"
card_view:cardBackgroundColor="@color/baseYellow"
android:layout_height="@dimen/retail_card_height">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView android:layout_width="match_parent" android:layout_height="match_parent"
tools:src="@drawable/ic_fruit_1"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:scaleType="fitEnd"
app:layout_constraintTop_toTopOf="parent"/>
<ImageView
android:id="@+id/ivRetailBrand"
android:layout_width="@dimen/brand_icon_size"
android:layout_height="@dimen/brand_icon_size"
tools:src="@drawable/esselunga"
android:layout_marginTop="@dimen/retail_brand_margin"
android:background="@drawable/round_outline"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="@dimen/retail_brand_margin"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
Unfortunately, neither cardCornerRadius
nor cardBackgroundColor
seem working on my layout. I can't understand if my issue depends on AndroidX libraries or not.
Here there's my layout preview:
I removed this lines in my Manifest file and after that my cardviews are worked prefectly fine
android:hardwareAccelerated="false"
Try modifying the CardView as:
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/retail_card_width"
app:cardCornerRadius="@dimen/card_radius"
app:cardBackgroundColor="@color/baseYellow"
android:layout_height="@dimen/retail_card_height">
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