Android Custom Snackbar: can't remove margins

前端 未结 4 1081
北海茫月
北海茫月 2021-01-20 12:45

Regardless of whether or not it is a good idea to create a custom Snackbar, I have a custom Snackbar and I can\'t seem to get rid of the margins. I\'ve tried several things

4条回答
  •  广开言路
    2021-01-20 13:40

    You shoud remove paddings from a parent view:

    View snackBarLayout = findViewById(R.id.mainLayout);
    Snackbar globalSnackbar = Snackbar.make(snackBarLayout, "", Snackbar.LENGTH_INDEFINITE);
    Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) globalSnackbar.getView();  
    
    layout.setPadding(0,0,0,0); 
    

提交回复
热议问题