The Material Design website claims that "On medium and expanded window sizes, like tablet and desktop, snackbars should scale horizontally to accommodate longer text strings". However, despite their claims, the snackbar isn't scaling horizontally in Landscape mode for tablet devices in our Android XML project.
This is what I have so far:
val snackBar = Snackbar.make(view, message, length)
vak params = snackBar.view.layoutParams as CoordinatorLayout.LayoutParams
params.width = ViewGroup.LayoutParams.MATCH_PARENT
snackBar.show()
but even with programmatically setting the width to MATCH_PARENT
, it only occupies about 60% of the screen width (see screenshot below). Does anyone know how I can get it to occupy the full screen width in Landscape mode?
I figured it out - the key was to add a sufficiently large value to maxWidth
like below
<item name="android:maxWidth"> 9999dp</item>