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
This is my workaround to solve this type of problem in androidx
using kotlin
fun showSnackBar(message: String) {
mContent?.let {
val snackbar = Snackbar.make(it, message, Snackbar.LENGTH_LONG)
val snackbarView = snackbar.view
val tv = snackbarView.findViewById(R.id.snackbar_text)
tv.setTextColor(Color.WHITE) //change the color of text
tv.maxLines = 3 //specify the limit of text line
snackbar.duration = BaseTransientBottomBar.LENGTH_SHORT //specify the duraction of text message
snackbar.show()
}
}
You need initialize mContent
inside onViewCreated
method like below
var mContent: View? = null
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
mContent = view
}