When I click Action button Snack bar shows only two line of text and third line not showing
this is XML content
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_menu_help" />
And I use this code in my activity
......
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Hello word1" + "\n" + "Hello word2" + "\n" + "Hello word3", Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
});
.......
Actually Android Snackbar
have a TextView
to show your text. So by setting Multi line in TextView
you can achieve your target. Try this code, it worked for me.
Snackbar snackbar = Snackbar.make(Yourview, "Your Text", Snackbar.LENGTH_LONG);
View sbView = snackbar.getView();
TextView textView = sbView.findViewById(android.support.design.R.id.snackbar_text);
// For multi-line text, limit max line count.
textView.setMaxLines(3);
snackbar.show();