Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrapping content height on a SnackBar

is there any way to make a SnackBar wrapping its text content?

You can look up my problem below:

here

As you can see the text ends at "contact us at...." and it should display the entire message.

Thank you!

like image 929
Fábio Carballo Avatar asked Aug 03 '15 21:08

Fábio Carballo


People also ask

How set height of SnackBar android?

setTextSize(24); //increase max lines of text in snackbar. default is 2. sbNoAct. show(); int height = sbView.

How do I change the height of my SnackBar in flutter?

SnackBar takes a widget as a child. SnackBar takes the height of the child to render. When you pass a container with height 200 it will set the snack bar's height 200. scaffoldKey.

What is the use of SnackBar?

Snackbar in android is a new widget introduced with the Material Design library as a replacement of a Toast. Android Snackbar is light-weight widget and they are used to show messages in the bottom of the application with swiping enabled. Snackbar android widget may contain an optional action button.

How do I add icons to SnackBar?

If you want to add an icon to the right of a snackbar, you need to do the following: SpannableStringBuilder buildetTextRight = new SpannableStringBuilder(); buildetTextRight. append(" "); buildetTextRight.


1 Answers

I believe that snackbar by default limits you to only 2 lines.

One thing that you could try is setting the textview inside snackbar to be multiline. Like so:

View snackbarView = snackbar.getView();
TextView textView = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text);
textView.setMaxLines(5);  //set the max lines for textview to show multiple lines

Let me know if that works or not

like image 146
Sree Avatar answered Sep 26 '22 02:09

Sree