question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Snackbar] Message text is cut off or not visible at all for multiline (maxActionInlineWidth)

See original GitHub issue

Hi, we came across this problem working on accessibility for our app.

Problem afaik the problem is caused in SnackbarContentLayout by the logic in onMeasure regarding updateViewsWithinLayout. I’m sure you are aware but just for the sake of completeness: First the message text is multiline so the layout changes to vertical, but after that it is re-evaluated and since the text has now the full width available it is single line again and therefore the layout changes back to horizontal. This leads to cutting off the message text or being not visible at all.

It might sound like an edge case at first but actually with font and display size in place (try out the largest option for both) this scenario can happen quite easily (especially in other languages) and frankly happens to us without trying to fabricate something.

Example Pixel 4XL, Android 11, Material Lib 1.2.1 (same outcome for 1.3.0-alpha03) font size: largest display size: largest

AppCompatActivity with Theme.MaterialComponents.Light.NoActionBar

Snackbar.make(binding.coordinatorLayout, "Hey, you are offline.", Snackbar.LENGTH_INDEFINITE)
   .setMaxInlineActionWidth(resources.getDimensionPixelSize(R.dimen.design_snackbar_action_inline_max_width))
    .setAction("Please try again"){}
    .show()

image

chross check, message text that always is multiline

Snackbar.make(binding.coordinatorLayout, "Hey, you are offline or have a bad connection.", Snackbar.LENGTH_INDEFINITE) 
   .setMaxInlineActionWidth(resources.getDimensionPixelSize(R.dimen.design_snackbar_action_inline_max_width))
   .setAction("Please try again"){}
   .show()

image

Would appreciate to hear from you since we need this to to provide a safe and accessible way to use our app for everyone.

I guess it is similar (or caused by the same bug) to this issue but it also seems it might got lost (with closing google issue tracker and no one assigned) or at least no update since 2019.

Please let me know if I can provide anything.

Thx in advance.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
drchencommented, Oct 6, 2021

Hi, I will take a look into the issue soon and I’m going to close the issue as duplicate to #781. : )

0reactions
daniel-tailoredcommented, Jan 12, 2022

The fix was submitted several days ago so it’s not released yet.

It will probably be released with 1.6 alpha versions I guess.

@drchen ah sry just saw the commit is not included in that release 🙈 thx for the reply anyways, since I wasn’t sure if it was towards my initial issue or the different one brought forward from @liweiyap

will check the next release/alpha then, hopefully it resolves the a11y problems 🤞 thx.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Multiline Snackbar - Stack Overflow
Just set the maxLines attribute of Snackbars Textview View snackbarView = snackbar.getView(); TextView textView = (TextView) snackbarView.
Read more >
Snackbar - Android Developers
Sets the max width of the action to be in the same line as the message. If the width is exceeded the action...
Read more >
Snackbars - Material Design
Snackbars provide brief messages about app processes at the bottom of the screen. ... Snackbar with non-opaque container with text still legible.
Read more >
Snackbar no longer slides onto screen - Issue Tracker - Google
It is intended to slide up with a flickering animation then stays up there even after the snack bar disappears? I am also...
Read more >
Material Design Snackbar in Android - How and When to Use
Snackbar is a part of Material Design, available via Android ... They may contain a text action, but no icons. ... It can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found