So I want to change the vertical padding on Android's SnackBar in a clean maintainable way.
I tried to use:
setPaddingandsetMarginon theFrameLayout,LinearLayoutandTextViewused to create the SnackBarincludeFontPadding,setLineSpacingandsetSingleLineon theTextView
But nothing seemed to work.
However, I found this answer:
In
dimens.xml.Use this:
<dimen name="design_snackbar_padding_horizontal">0dp</dimen>But remember that this will get applied to all the snackbars in your application.
Which does work, but the ugly way, it's applied to all the SnackBars in the app and it's not safe since I'm overriding a private property that maybe renamed or removed in the future.
I'm trying to create something similar and Facebook Messenger's (previously) and Youtube's (Funny enough, Google) internet connection indicator:
Snackbar.make(container, message, duration).apply {
    val snackBarView = view.apply {
        setBackgroundColor(ContextCompat.getColor(this@MainActivity, connectivity.color))
    }
    (snackBarView.findViewById(com.google.android.material.R.id.snackbar_text) as TextView).apply {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
            textAlignment = View.TEXT_ALIGNMENT_CENTER
        else
            gravity = Gravity.CENTER
    }
}.show()
So this's what i'm expecting and am getting using the answer provided above:
And this's what i'm actually getting:
Thanks in advance!

