6 Modifying the bottom sheet's appearance - michael-rapp/AndroidBottomSheet GitHub Wiki

The class BottomSheet.Builder provides various methods, which can be used to customize the appearance of bottom sheets. The following table gives an overview of these methods and shows the default values, which are used when not overridden.

Setter methods Description Default value Restrictions
setTitleColor(int):Builder Sets the color of the bottom sheet's title. ?android:attr/textColorSecondary Must be a valid color, not a resource ID.
setItemColor(int):Builder Sets the color of the bottom sheet's items. ?android:attr/textColorPrimary Must be a valid color, not a resource ID.
setBackground(Drawable):Builder setBackground(int):Builder setBackgroundColor(int):Builder Sets the bottom sheet's background. ?android:attr/background When specified via a resource ID, the resource ID must correspond to a valid drawable resource.
setDividerColor(int):Builder Sets the color of the bottom sheet's dividers. R.color.divider_light or R.color.divider_dark depending on the theme Must be a valid color, not a resource ID.
setDimAmount(float):Builder Sets the transparency of the overlay, which is used to darken the area outside the bottom sheet. 0.25 Must be between 0 (fully transparent) and 1 (fully opaque).

If a bottom sheet, which is created by the class BottomSheet.Builder, should use a dark theme, instead of the default light one, the theme's resource id can be passed to the builder's constructor. By default, the theme R.style.BottomSheet_Light is used. If the dark theme should be used, the resource id R.style.BottomSheet has to be passed to the constructor. The screenshot below illustrates the appearance of a bottom sheet, which uses the dark theme:

Besides using the predefined themes, it is also possible to extend these themes in an app's style.xml by specifying custom theme attributes. If the light theme should be used as a starting point, the new theme's parent must be @style/BottomSheet.Light, if the dark theme should be used instead, the parent must be set to @style/BottomSheet. The following table shows all available theme attributes:

Theme attribute Description Format
bottomSheetTitleColor Specifies the color of the bottom sheet's title. color
bottomSheetItemColor Specifies the color of the bottom sheet's items. color
bottomSheetDividerColor Specifies the color of the bottom sheet's dividers. color
bottomSheetDimAmount Specifies the dim amount of the bottom sheet. fraction
bottomSheetBackground Specifies the bottom sheet's background. color or reference