material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[Snackbar] Could not change snackbar width when migrated material design from 1.3.0 to 1.5.0

Open maximiliano-ferraiuolo-vas opened this issue 3 years ago • 3 comments
trafficstars

Description: Not sure if this is an issue, but this was working on material 1.3.0, after upgrading to 1.5 and above, if we want to update the width of the Snackbar programatically won't work.

Expected behavior: I expect the snackbar to take the match_parent of the view.

Source code: The followign code use to work to make the Snackbar full width / matching parent., after updating from material 1.3.0 to 1.6.1, this has no effect.

       val customSnackbar =
                CustomSnackbar(view.parent as ViewGroup, binding.customSnackBarView).apply {
                    this.duration = duration
                    getView().layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT
                    binding.customSnackBarView.imageClose.setOnClickListener { dismiss() }
                }

Minimal sample app repro: Please consider attaching a minimal sample app that reproduces the issue. This will help narrow down the conditions required for reproducing the issue, and it will speed up the bug fix process. You may attach a zip file of the sample app or link to a GitHub repo that contains the sample app.

Android API version:

 compileSdkVersion 31
    buildToolsVersion "30.0.3"
    defaultConfig {
        applicationId "com.xxx.xxxxxx"
        minSdkVersion 23
        targetSdkVersion 30
        versionCode 20701
        versionName "2.7.0"

Material Library version: implementation 'com.google.android.material:material:1.6.1

Device: Pixel C on Landscape mode.

Thanks!

After updating to materian 1.6.1 snackbar displays as follows: Screenshot 2022-09-12 at 19 47 21 this was before the update, with material 1.3.0 image

We also happily accept pull requests.

Hi can you provide you screenshots before/after you upgrade the version so we can know better what visual effect you are trying to achieve?

drchen avatar Sep 12 '22 18:09 drchen

Sure, I just updated the comment with the screenshots. thanks!

Did you inspect the layout? Do you know where the margins are coming from?

drchen avatar Sep 13 '22 16:09 drchen

I'll close this issue for now due to no further info available. Please feel free to reopen it if this is still an issue.

drchen avatar Sep 29 '22 20:09 drchen