How to align message textview to the center Horizontally in snackbar in android?
Below is a sample, for making the Snackbar Text center horizontal
Snackbar snackbar = Snackbar.make(findViewById(R.id.coordinatorLayout), "Hello", Snackbar.LENGTH_SHORT);
snackbar.show();
View view = snackbar.getView();
TextView txtv = (TextView) view.findViewById(android.support.design.R.id.snackbar_text);
txtv.setGravity(Gravity.CENTER_HORIZONTAL);
If you are using androidX
then replace the textview
id com.google.android.material.R.id.snackbar_text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With