How to change background color of the snackbar?

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

    While Working with xamarin android I found out that ContextCompat.GetColor() returns Int but the setBackgroundColor() expects a Parameter of type Color. So here is how I got it working in my xamarin android project.

    Snackbar snackbarview =  Snackbar.Make(toolbar, message, Snackbar.LengthLong);
    View snckView = snackbarview.View;                
    snckView.SetBackgroundColor(Color.ParseColor(GetString(Resource.Color.colorPrimary)));
    snackbarview.Show();
    

提交回复
热议问题