I have a material cardview as a root item. I want to add rounded top left and right to it. I added these attributes to its style but it is changed a little and not work properly.
ItemForRV:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView
android:layout_width="@dimen/_150sdp"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
style="@style/CardViewRoundedtop"
xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<com.google.android.material.textview.MaterialTextView
android:background="@color/primaryColor"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/imgFastfood"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
tools:text="FastFood"
android:id="@+id/TVNameCategory"
/>
<ImageView
app:layout_constraintTop_toBottomOf="@id/TVNameCategory"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_width="match_parent"
android:layout_height="@dimen/_110sdp"
tools:src="@drawable/fastfood"
android:id="@+id/imgFastfood"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
Style:
<style name="CardViewRoundedtop" parent="Widget.MaterialComponents.CardView">
<item name="android:topLeftRadius">16dp</item>
<item name="android:topRightRadius">16dp</item>
<item name="android:bottomLeftRadius">0dp</item>
<item name="android:bottomRightRadius">0dp</item>
</style>
P.S: I read about a bug that I had to change bottom left/right radius to 1dp. it did not help at all.
Now:
Something I expect:
for showing here I used app:cardCornerRadius="16dp" and it is set all four corner.
Edit: I used "cornerSizeTopRight". it seems it works in different way.