How to change background color of the snackbar?

后端 未结 16 800
温柔的废话
温柔的废话 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:05

    Basically, the solutions that were provided have one disadvantage. They change the shape of snackbar and remove the radius.

    Personally, prefer something like that

    val snackbar = Snackbar.make(view, text, Snackbar.LENGTH_LONG);
    val view = snackbar.getView();
    val color = view.resources.getColor(colorId)
    view.background.setColorFilter(color, PorterDuff.Mode.SRC_ATOP)
    

提交回复
热议问题