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

前端 未结 22 2864
温柔的废话
温柔的废话 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 13:03

    If you are in Kotlin, you can create an extension :

    fun Snackbar.withTextColor(color: Int): Snackbar {
        val tv = this.view.findViewById(android.support.design.R.id.snackbar_text) as TextView
        tv.setTextColor(color)
        return this
    }
    

    Usage :

    yourSnackBar.withTextColor(Color.WHITE).show()
    

提交回复
热议问题