【问题标题】:Is it possible to print multiple lines on snackbar ? Is there is word limit? [duplicate]是否可以在snackbar 上打印多行?有字数限制吗? [复制]
【发布时间】:2016-01-19 23:20:30
【问题描述】:

我知道 Snackbar 只是显示一条短消息。但是对于我的一个来说,它要求我打印多行。这可能吗?

【问题讨论】:

标签: android snackbar


【解决方案1】:

默认情况下它只支持最多 2 行。如果你想增加它,你可以通过下面的方式改变设置snackBar textview Max line的属性。

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

【讨论】:

    【解决方案2】:

    是的,这是可能的。您可以尝试将“\n”放在两行之间。 (虽然,在小吃店上放很多行可能看起来不太好)

    例子:

    Snackbar.make(view, "This is first line\nThis is second line", Snackbar.LENGTH_SHORT).show();
    

    【讨论】:

      猜你喜欢
      • 2018-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-11
      • 1970-01-01
      • 2022-01-23
      • 1970-01-01
      相关资源
      最近更新 更多