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

前端 未结 22 2816
温柔的废话
温柔的废话 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:46

    Currently (January 2020) with com.google.android.material:material:1.2.0 and probably also 1.1.0

    Is definitely the best way how to do it by overrides these styles:

    @style/Widget.MaterialComponents.Snackbar
    @style/Widget.MaterialComponents.Button.TextButton.Snackbar
    @style/Widget.MaterialComponents.Snackbar.TextView
    

    If you use a material theme with .Bridge at the end, for some reason, neither of these styles are defined. So Snackar will use some legacy layout without these styles.

    I found in the source code that both snackbarButtonStyle and snackbarTextViewStyle must be defined otherwise it will be not used.

提交回复
热议问题