【问题标题】:Wrapping content height on a SnackBar在 SnackBar 上包装内容高度
【发布时间】:2015-10-26 03:04:50
【问题描述】:

有没有办法让 SnackBar 包装其文本内容?

你可以在下面查看我的问题:

如您所见,文本以“contact us at....”结尾,它应该显示整个消息。

谢谢!

【问题讨论】:

    标签: android android-support-design snackbar


    【解决方案1】:

    我相信,snackbar 默认情况下将您限制为 2 行。

    您可以尝试的一件事是将小吃栏中的 textview 设置为多行。像这样:

    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
    

    让我知道这是否有效

    【讨论】:

    • 2020解决方案:snackbar.view.findViewById<TextView>(com.google.android.material.R.id.snackbar_text).maxLines = 5
    猜你喜欢
    • 2023-02-01
    • 2020-09-06
    • 1970-01-01
    • 1970-01-01
    • 2021-11-11
    • 1970-01-01
    • 2022-07-26
    • 2017-12-31
    • 2021-11-29
    相关资源
    最近更新 更多