[Snackbar] Message text is cut off or not visible at all for multiline (maxActionInlineWidth)
See original GitHub issueHi, 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()
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()
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:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
Hi, I will take a look into the issue soon and I’m going to close the issue as duplicate to #781. : )
@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.