Development issue/problem:

I already know that BottomSheetDialog does this, but I need to use the normal BottomSheet and the behaviour that BottomSheetBehavior.from() generates. This BottomSheet does not obscure the background or touch the outside to obscure it. Is there any way to reduce the brightness of the background when displaying the bottom sheet… …and possibly deflect when tapping the outside? In principle the behaviour is the same as with BottomSheetDialog, but I have to use BottomSheet BottomSheetBehavior directly.

Thank you so much!

How can I solve this problem?

Solution 1:

You can use this code
1. MainActivity.xml


The MainActivity public class expands AppCompatActivity, implements View.OnClickListener {

private static end string TAG = MainActivity;
private BottomSheetBehavior mBottomSheetBehavior;
Bottom Sheet View;
Bottom Sheet View mViewBg ;

protected void onCreate(Bundle savedInstanceState) {
bottomSheet= findViewById(;
mViewBg = findViewById(;
button1 = (button) findViewById(;
mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
mBottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_COLLLAPSED)

public void onSlide(@NonNull View bottomSheet, float slideOffset) {
Log.d(TAG, onSlide: slideOffset + slideOffset + );


@Overriderblic void onClick(View v) { switch (v.getId()) {register {mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);break;}}}}.

public logic sendTochevent(event MotionEvent) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED) {
Rect outRect = new Rect();
if (!outRect.contains((int) event.getRawX(), (int) event.getRawY()))) {
return true;

return super.dispatchTouchEvent(event);


Solution 2:

You can create a custom cutout with a layout below (bottom view) and make the background transparent_black, and when you click on this BG, remove this cutout. Ex:


The MainActivity public class expands AppCompatActivity {

The BottomSheetFragment is the lowest fragment of the sheet;

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState) ;
setContentView(R.layout.activity_main) ;

findViewById( View.OnClickListener() {
public blank onClick(View view)) {

if (bottomSheetFragment ==zero) {bottomSheetFragment = new BottomSheetFragment();}getSupportFragmentManager().beginTransaction().add(, bottomSheetFragment).addToBackStack(null).commit() ;



public void removeBottomSheet() {
try {
} catch (Exception e) {



public class BottomSheetFragment expands Fragment {

private View rootView;
private LayoutInflater layoutInflater ;

public void onCreate(Bundle savedInstanceState) {
layoutInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE) ;


General view
onCreate view(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.bottom_sheet_layout, container, false);
rootView.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// remove sheet on BG touch
((MainActivity) getActivity()).removeBottomSheet();
return rootView;



To get this extract with bottom_top/animation…. you can go to this link: Android clips and animations

Solution 3:

You can use my concept if you want to use me in AlertDialog with a blurred background in the middle of the transitions.

My approach

  1. Take a screenshot
  2. Program animated blur/gradient screen section
  3. Getting the current window via the wizard dialog has no content
  4. Confirm a screenshot with the effect
  5. Show me the real view I wanted to show you

Here I have a course to create the background image as a bitmap.

public class AppUtils {

public static bitmap takeScreenShot(Activity activity) {
View = activity.getWindow().getDecorView() ;
view.setDrawingCacheEnabled(true) ;
view.buildDrawingCache() ;

Bitmap b1 = view.getDrawingCache();
Rect frame = new Rect();
int statusBarHeight = ;

Display = active.getWindowManager().getDefaultDisplay();
Point Size = new Point();
int width = size.x;
int height = size.y ;

Bitmap b = Bitmap.createBitmap(b1, 0, statusBarHeight, width, height – statusBarHeight);
return b;

Congratulations, you now have a darker/blinded image, just like your background.

Your requirement would then be to darken, not fade as I did, so you can pass this bitmap to the method below,

public static change bitmapBitmapContrastBrightness(Bitmap bmp, float contrast, float brightness) {
ColorMatrix cm = new ColorMatrix(new float[] {
contrast, 0, 0, brightness,
0, contrast, 0, brightness,
0, 0, contrast, 0, brightness,
0, 0, 1, 0

Bitmap ret = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), bmp.getConfig()) ;

Canvas = new canvas(ret) ;

Paint paint = new Paint() ;
paint.setColorFilter(new ColorMatrixColorFilter(cm)) ;
canvas.drawBitmap(bmp, 0, 0, paint) ;


Now, use a fake dialog / dialogue with a background / content of Cutout only to get a window (check my implementation questions, you can understand this)

Window = fakeDialogUseToGetWindowForBlurEffect.getWindow();
window.setBackgroundDrawable(draw); // draw is a bitmap you created.

In my case I will display a warning, you can display what you want, and don’t forget to erase/remove this warning if your current display disappears from the screen!

Quickly turn it off: (the background can be adjusted as desired, not just dimmed).

How can i dim the background when Bottomsheet is displayed, without using Dialog? –

Solution 4:

With the interface – onSlide, which has a slideOffSet parameter, the background can be muted. A new offset of this lower wing in the range [-1,1]. The displacement increases as the lower plate moves upwards. From 0 to 1 the sheet lies between the folded and unfolded state, from -1 to 0 between the hidden and folded state.

as ( slideOffSet>=0 && slideOffSet

where mainActivityLayoutView is the identifier of NestedScrollView, which contains the main content of the activity.

Solution No 5:

Use this style and apply it to your dialogue.

PS: this style also works very well on Android 6.0, 6.1 and 7.0.

And use as:

Last dialog mBottomSheetDialog = New dialog mActivity, ;

Thank you so much!

Good luck!

bottom sheet shadow'' android,bottomsheetdialog rounded corners,bottom sheet fragment background,bottomsheetdialogfragment not modal,bottom sheet dialog fragment,android bottom sheet transparent background,bottom sheet transparent android,bottom sheet rounded corners android,blur kit android,android bottomsheet transparent background,bottomsheetdialogfragment navigation bar,bottomsheetdialogfragment menu,bottom sheet for android app bar,android bottom sheet share,bottomsheetdialogfragment status bar color,android dialog change navigation bar color,bottomsheetdialog android example,bottomsheetdialog androidx,cannot resolve symbol bottomsheetdialog,bottomsheetdialog flutter,bottomsheetdialog react-native,dialog vs bottom sheet,android bottom sheet dialog margin,bottom sheet example in android,bottom sheet with scrollview android,android bottom sheet slide up animation,android bottom sheet anchor,android bottom sheet expand to full screen,android bottom sheet dialog transparent background,make bottom sheet dialog transparent,make bottomsheetdialog background transparent,bottomsheetbehavior,bottomsheetdialogfragment,bottom sheet dialog fragment disable drag,bottom sheet dialog set background transparent

You May Also Like

P2P | What Is P2P (Peer-to-Peer) Definition

What is P2P? In P2P media, a number of servers are associated…

Launch a Professional Website in Under 30 Minutes

In today’s theme discussion we take a look at the Izo WordPress…

Gradle sync failed, NDK not configured, download it with SDK manager –

Development issue/problem: I’m completely new in Android development and I just installed…

Analyzing Android Project with Lint and SonarQube –

Development issue/problem: I’ve been very busy making the connection between these things.…