How to change background color of the snackbar?

后端 未结 16 801
温柔的废话
温柔的废话 2020-12-07 19:28

I am showing snackbar in DialogFragment Within the Positive click of alertDialog. Here is my code snippet.

Snackbar snackbar = Snackbar.make(view, \"Please e         


        
16条回答
  •  半阙折子戏
    2020-12-07 20:19

    public class CustomBar {
    
    public static void show(View view, String message, boolean isLong) {
        Snackbar s = Snackbar.make(view, message, isLong ? Snackbar.LENGTH_LONG : Snackbar.LENGTH_SHORT);
        s.getView().setBackgroundColor(ContextCompat.getColor(view.getContext(), R.color.red_900));
        s.show();
    }
    
    public static void show(View view, @StringRes int message, boolean isLong) {
        Snackbar s = Snackbar.make(view, message, isLong ? Snackbar.LENGTH_LONG : Snackbar.LENGTH_SHORT);
        s.getView().setBackgroundColor(ContextCompat.getColor(view.getContext(), R.color.red_900));
        s.show();
    }
    

    }

提交回复
热议问题