-1

bottomsheet upper round corner

This is what I want to achieve. The root of my bottom sheet is MaterialCardView. Below are the methods I tried and didn't get the exact result:

  1. Added background drawable directly and setBackgroundColor(Color.TRANSPARENT).

  2. Added background drawable in the styles.xml and then adding that style to the MaterialCardView.

  3. Added cardCornerRadius to MaterialCardView and adjusted the inset.

Can anyone help me please?

Prosenjith Roy
  • 179
  • 1
  • 1
  • 9

1 Answers1

0

I would recommend instead of using Material Card View, you simply give a background to your parent layout. You can create a drawable as follows

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="@android:color/white"/>
    <corners android:topLeftRadius="16dp"
        android:topRightRadius="16dp"/>

</shape>

The thing with MaterialCardView is that, it does not have the utility to apply corner radius to a specific corner as far as I know. So you can just simply use and assign a custom drawable.

Also there is a library called Material Dialogs. That might help you out even more if you do not want to do it all by yourself.

che10
  • 2,176
  • 2
  • 4
  • 11
  • I applied the first technique, Removed the MaterialCardView, Used LinearLayout as root and set background both in xml and programatically. still not working. – Prosenjith Roy Aug 02 '21 at 08:45