I know Snackbar is just to show a short message.But for one of my it's asking me to print multiple line.Is that possible ?
Asked
Active
Viewed 5,420 times
1
-
3http://stackoverflow.com/questions/30705607/android-multiline-snackbar/31429069#31429069 – Nilesh Senta Dec 10 '15 at 05:01
2 Answers
13
By Default it only support max of 2 lines. if you want to increase it you can change the attribute of setting Max line of snackBar textview by below way.
View yourSnackBarView = snackbar.getView(); //get your snackbar view
TextView textView = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text); //Get reference of snackbar textview
textView.setMaxLines(3); // Change your max lines

Bhavesh Patadiya
- 25,740
- 15
- 81
- 107
-1
Yes, it's possible. You can try to put "\n" in between your lines. (Although, It may not look nice to put many lines on a snackbar)
Example:
Snackbar.make(view, "This is first line\nThis is second line", Snackbar.LENGTH_SHORT).show();

Hungry Coder
- 1,800
- 17
- 22