-1

I have SnackBar with text but i need more than one line.

this is my code:

import android.support.design.widget.Snackbar;

final String snack = "LINE1\nLINE2\nLINE3";
Snackbar.make(view, snack, Snackbar.LENGTH_LONG).show();

there is a way to do it with SnackBar?

Yoni
  • 1,300
  • 3
  • 16
  • 37
YealBen
  • 25
  • 4

2 Answers2

3

try this you have to use maxLines attribute of Snackbars Textview

Snackbar snackbar =  Snackbar.make(view, "LINE1\nLINE2\nLINE3",Snackbar.LENGTH_LONG).setDuration(Snackbar.LENGTH_LONG);
View snackbarView = snackbar.getView();
TextView textView = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text);
textView.setMaxLines(5);
snackbar.show();
AskNilesh
  • 63,753
  • 16
  • 113
  • 150
0

you may try this

View mySnackbarView= snackbar.getView();
TextView tv= (TextView) mySnackbarView.findViewById(android.support.design.R.id.snackbarText);
tv.setMaxLines(2); 
Arpit Prajapati
  • 367
  • 2
  • 16