Add margins to Snackbar view

前端 未结 17 1469
时光取名叫无心
时光取名叫无心 2020-12-06 16:20

I\'m updating my current app to use snackbars, in the Google spec they show various ways of using them http://www.google.com/design/spec/components/snackbars-toasts.html#sna

17条回答
  •  萌比男神i
    2020-12-06 17:15

    To set margin:

    View viewInSnk = snkbr.getView();
    ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) snkbr.getView().getLayoutParams();
    params.setMargins(5, 5, 5, 5);
    snkbr.getView().setLayoutParams(params);
    

    and to set round corner:

    viewInSnk.setBackgroundDrawable(getResources().getDrawable(R.drawable.snackbar_shape));
    

    and for shape :

    
        
        
    
    

提交回复
热议问题