How to set support library snackbar text color to something other than android:textColor?

前端 未结 22 2396
温柔的废话
温柔的废话 2021-01-30 12:33

So I\'ve started using the new Snackbar in the Design Support Library, but I found that when you define \"android:textColor\" in your theme, it applies to the text color of the

22条回答
  •  时光说笑
    2021-01-30 12:53

    Find by id did't work for me so I found another solution:

    Snackbar snackbar = Snackbar.make(view, text, duration);//just ordinary creation
    
    ViewGroup snackbarView = (ViewGroup) snackbar.getView();
    SnackbarContentLayout contentLayout = (SnackbarContentLayout) snackbarView.getChildAt(0);
    TextView tvText = contentLayout.getMessageView();
    tvText.setTextColor(/*your color here*/);
    
    //set another colors, show, etc
    

提交回复
热议问题