Round corner for BottomSheetDialogFragment

rounded bottom sheet android github
bottomsheetdialog vs bottomsheetdialogfragment
custom bottom sheet dialog android example
bottom sheet rounded corners flutter
bottomsheetdialogfragment padding
custom bottom sheet dialog android github
bottomsheetdialogfragment transparent background
bottomsheetdialogfragment rounded

i have an custom BttomSheetDialogFragment and i want to have round corners in top of Bottom View

this is my Custom class that inflating my layout that i want to appear from bottom

View mView;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mView = inflater.inflate(R.layout.charge_layout, container, false);
    initChargeLayoutViews();
    return mView;
}

and also i have this xml resource file as background :

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<corners android:topRightRadius="35dp"
    android:topLeftRadius="35dp"
    />
<solid android:color="@color/white"/>

<padding android:top="10dp"
    android:bottom="10dp"
    android:right="16dp"
    android:left="16dp"/>

but the problem is, when i set this resource file as background of my Layout's root element , the corners still are not rounded

and i can't use below code :

    this.getDialog().getWindow().setBackgroundDrawableResource(R.drawable.charge_layout_background);

cuz its override default background of BottomSheetDialog and there wont be any semi-transparent gray color above my Bottom View


Create a custom drawable rounded_dialog.xml:

<?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>

Then override bottomSheetDialogTheme on styles.xml using the drawable as background:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">       
    <item name="bottomSheetDialogTheme">@style/AppBottomSheetDialogTheme</item>
</style>

<style name="AppBottomSheetDialogTheme"
    parent="Theme.Design.Light.BottomSheetDialog">
    <item name="bottomSheetStyle">@style/AppModalStyle</item>
</style>

<style name="AppModalStyle"
    parent="Widget.Design.BottomSheet.Modal">
    <item name="android:background">@drawable/rounded_dialog</item>
</style>

This will change all the BottomSheetDialogs of your app.

How to put rounded corners in a BottomSheetDialogFragment , I have problems trying to put rounded edges, since I show it as modal, and I want its upper corners to be rounded, I find examples but  I have problems trying to put rounded edges, since I show it as modal, and I want its upper corners to be rounded, I find examples but everything is for Android-Java, apart because I see that they create a style-v21 file, but I don't know how to use it


The BottomSheetDialog is setting a default white background color , this is why the corners are not visible, In order to show them you need to make the background of the dialog transparent by overriding the style of the BottomSheetDialog.

Define this style In your res/values/styles/styles.xml

<style name="BottomSheetDialog" parent="Theme.Design.Light.BottomSheetDialog">
    <item name="bottomSheetStyle">@style/bottomSheetStyleWrapper</item>
</style>

<style name="bottomSheetStyleWrapper" parent="Widget.Design.BottomSheet.Modal">
    <item name="android:background">@android:color/transparent</item>
</style>

And set this style to your BottomSheetDialog

View view = getLayoutInflater().inflate(R.layout.chooser_bottom_sheet, null);
BottomSheetDialog dialog = new BottomSheetDialog(this,R.style.BottomSheetDialog); // Style here
dialog.setContentView(view);
dialog.show();

Rounded modal bottom sheet as seen in new Google products , Rounded modal bottom sheet as seen in new Google products(Tasks, News, etc <corners. android:topLeftRadius="@dimen/bottom_sheet_corner_radius" open class RoundedBottomSheetDialogFragment : BottomSheetDialogFragment​()  I am using this solution to round corners of dialog in BottomSheetDialogFragment and it works fine with API 21 and higher. But in Api < 21 it removes the background and the rounded background goes away. How to make the background rounded in API < 21? If it is not possible to change the background, please help me change the background color instead.


With the new Material Component library you can customize the shape of your component using the shapeAppearanceOverlay attribute in your style.

Just use the BottomSheetDialogFragment overriding the onCreateView method and then define your custom style for Bottom Sheet Dialogs.

Define the bottomSheetDialogTheme attribute in styles.xml in your app theme:

  <!-- Base application theme. -->
  <style name="AppTheme" parent="Theme.MaterialComponents.Light">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    ....
    <item name="bottomSheetDialogTheme">@style/CustomBottomSheetDialog</item>
  </style>

Then just define your favorite shape with shapeAppearanceOverlay

  <style name="CustomBottomSheetDialog" parent="@style/ThemeOverlay.MaterialComponents.BottomSheetDialog">
    <item name="bottomSheetStyle">@style/CustomBottomSheet</item>
  </style>

  <style name="CustomBottomSheet" parent="Widget.MaterialComponents.BottomSheet">
    <item name="shapeAppearanceOverlay">@style/CustomShapeAppearanceBottomSheetDialog</item>
  </style>

  <style name="CustomShapeAppearanceBottomSheetDialog" parent="">
    <item name="cornerFamily">rounded</item>
    <item name="cornerSizeTopRight">16dp</item>
    <item name="cornerSizeTopLeft">16dp</item>
    <item name="cornerSizeBottomRight">0dp</item>
    <item name="cornerSizeBottomLeft">0dp</item>
  </style>

It requires the version 1.1.0 (currently the latest version is 1.1.0-beta02).

Implementing Google's refreshed modal bottom sheet, for Android, then implementing this rounded corner bottom sheet got much easier. Rounded BottomSheetDialog fragment without dimmed  com.google.android.material.bottomsheet.BottomSheetDialogFragment. Modal bottom sheet. This is a version of DialogFragment that shows a bottom sheet using BottomSheetDialog instead of a floating dialog. Inherited constants. From class androidx.fragment.app.DialogFragment. Public constructors. BottomSheetDialogFragment ()


I was checking the same thing today and yes you were right about following code

this.getDialog().getWindow().setBackgroundDrawableResource(R.drawable.charge_layout_background);

this applies to fragment background, so instead you should get the bottomsheet view from dialog window and change the background here is the code

 @SuppressLint("RestrictedApi")
    @Override
    public void setupDialog(Dialog dialog, int style) {
        super.setupDialog(dialog, style);
        View rootView = getActivity().getLayoutInflater().inflate(R.layout.view_member_info,null,false);
        unbinder = ButterKnife.bind(this, rootView);
        adjustUIComponents();
        dialog.setContentView(rootView);
        FrameLayout bottomSheet = (FrameLayout) dialog.getWindow().findViewById(android.support.design.R.id.design_bottom_sheet);
        bottomSheet.setBackgroundResource(R.drawable.container_background);
    }

here bottomsheet is the actual view you want to change.

RoundedCornerTreatment, i have an custom BttomSheetDialogFragment and i want to have round corners in top of Bottom View this is my Custom class that inflating my layout that i want to  Thanks for opening project, but I think there are some parts that missing. File google-services.json is missing. The Google Services Plugin cannot function without it.


create a shape named rounded_corners_shape

<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <corners
        android:topLeftRadius="8dp"
        android:topRightRadius="8dp"/>
    <solid android:color="@color/white"/>

</shape>

define a style

  <style name="AppBottomSheetDialogTheme"
           parent="Theme.Design.Light.BottomSheetDialog">
        <item name="bottomSheetStyle">@style/AppModalStyle</item>
    </style>

    <style name="AppModalStyle" parent="Widget.Design.BottomSheet.Modal">
        <item name="android:background">@drawable/rounded_corners_shape</item>
    </style>

use this style on your custom BottomSheetDialogFragment like this, it will be work!

 public class CustomDialogFragment extends BottomSheetDialogFragment {
      @Override
      public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(STYLE_NORMAL, R.style. AppBottomSheetDialogTheme);
      }

      ...
    }

Android BottomSheetDialogFragment has color behind rounded , i have an custom BttomSheetDialogFragment and i want to have round corners in top of Bottom View. this is my Custom class that inflating my  AutoCompleTextView + BottomSheetDialogFragment + CustomAdapter Rubens Armôa Lopes. CorelDraw X7- How to design an Amazing Round Logo - Duration: 26:32. Akin The Computer Guy Recommended


Applying shape to UI, float : the radius, in pixels, of the rounded corner, which is rendered as a quarter circle. Public methods. getCornerPath. void getCornerPath (  In this tutorial we will learn, how to create a modal bottom sheet, by subclassing BottomSheetDialogFragment. Our sheet will have a custom layout and it will be able to communicate back to the


BottomSheetDialogFragment view becomes transparent only after , Android BottomSheetDialogFragment has color behind rounded corners You have to change the bottom sheet theme to achieve the top round layout Create a​  With the Arrival of the new version 23.2 of library support Android brings a new component that can enrich the user interface of some of our applications, calls Bottom Sheets. You can find a detailed description of this component in the guides design of Material design. What is Bottom Sheets ? A bottom sheet is Continue Reading


Components can apply one of two styles to the shapes of their corners: Rounded corner; Cut corner. A rounded corner. Android Bottom Sheet component slides up from the bottom showing more relevant content. You can notice bottom sheets in apps like map apps (bottom sheet reveals location, directions information), music players (Play bar sticks to bottom and opens when swipe up). The bottom sheet is the component of android design support library.