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

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

    If you decide to use the dirty and hacky solution with finding TextView in Snackbar by id and you already migrated to androidx, then here's the code:

    val textViewId = com.google.android.material.R.id.snackbar_text
    val snackbar = Snackbar.make(view, "Text", Snackbar.LENGTH_SHORT)
    val textView = snackbar.view.findViewById(textViewId) as TextView
    textView.setTextColor(Color.WHITE)
    

提交回复
热议问题