Friday, July 24, 2020

Customizing a Snackbar in Android

In Android we can customize a Snackbar
We can change the Text Color, Action text color, Background color and chnage/add an image



 TextView mainTextView = (TextView) (mSnackBar.getView()).findViewById(android.support.design.R.id.snackbar_text);
            TextView actionTextView = (TextView) (mSnackBar.getView()).findViewById(android.support.design.R.id.snackbar_action);

// change background color
            mSnackBar.getView().setBackgroundColor(Color.WHITE);
            Typeface font = Typeface.createFromAsset(getAssets(), "LatoRegular.ttf");
// Change the Font
            mainTextView.setTypeface(font);
            actionTextView.setTypeface(font);
// Change the colors
            mainTextView.setTextColor(Color.BLACK);
            actionTextView.setTextColor(Color.BLACK);

2 comments: