material-components / material-components-android

Modular and customizable Material Design UI components for Android
Apache License 2.0
16.38k stars 3.07k forks source link

[BottomSheetDialog] MaterialButton in BottomSheetDialog will be forced to single-line #2333

Closed Back4fire closed 3 years ago

Back4fire commented 3 years ago

MaterialButton in BottomSheetDialog will be forced to single-line. With the Layout Inspector, I found singleLine==ture and maxLines==1. But I never set these values explicitly. The bug starts from Material 1.4.0. And still exists in 1.5.0-alpha02.

The following is a very simple layout, a Button in a FrameLayout.

<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="300dp">

<Button
    android:id="@+id/button"
    android:layout_width="150dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="I will be forced to be single-line in Bottom Sheet Dialog with Material Lib 1.4.0+" />

device-2021-08-15-165518 This screenshot is compiled with Material 1.3.0. Everything is correct.

device-2021-08-15-165609 This screenshot is compiled with Material 1.4.0. The Button is single-line.

SourceCode.zip

The layouts in my project related to this bug are broken. If there is any workaround before it can be fixed, please let me know.

Back4fire commented 3 years ago

Thanks.

sds100 commented 3 years ago

Thanks.

how come you closed this? I haven't fixed it πŸ˜„

Back4fire commented 3 years ago

I thought the MD team doesn't treat it as a bug.😁 But it's unreasonable to make the style of MaterialButton in BottomSheetDialog like that in AlertDialog. We usually put complicated UI in BottomSheetDialog.

sds100 commented 3 years ago

I thought the MD team doesn't treat it as a bug.😁 But it's unreasonable to make the style of MaterialButton in BottomSheetDialog like that in AlertDialog. We usually put complicated UI in BottomSheetDialog.

Yeah, I agree

drchen commented 3 years ago

Yes, it's working as designed.

If you want to change the button style, you can extend ThemeOverlay.MaterialComponents.BottomSheetDialog and override ?attr/MaterialButtonStyle to the style you like, and set your main theme's ?attr/bottomSheetDialogTheme to the custom theme.