I want to make the layout of a BottomSheet with rounded corners, but setting a drawable with corner radius does not clip the layout background.
I am using a BottomSheetDialogFragment
.
fragment_a.xml
<androidx.constraintlayout.widget.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/round_rectangle">
<!-- other views here -->
</androidx.constraintlayout.widget.ConstraintLayout>
round_rectangle.xml
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid
android:color="@android:color/white" />
<stroke
android:width="2dp"
android:color="#C4CDE0" />
<padding
android:left="0dp"
android:right="0dp"
android:top="0dp"
android:bottom="0dp" />
<corners
android:topLeftRadius="16dp"
android:topRightRadius="16dp" />
</shape>
Current result:
Tried:
Clipping programetically using
view.clipToOutline = true
Please help! Thanks in advance!