Wrapping content height on a SnackBar
Asked Answered
C

1

15

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!

Counterblast answered 3/8, 2015 at 21:18 Comment(0)
D
37

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

Donnell answered 3/8, 2015 at 21:27 Comment(1)
2020 solution: snackbar.view.findViewById<TextView>(com.google.android.material.R.id.snackbar_text).maxLines = 5Cypripedium

© 2022 - 2024 — McMap. All rights reserved.