Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Material design components button global theme overriding broken

I want to simply apply styling to all buttons on a theme level like this

<style name="BaseTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
     ...    
    <item name="buttonStyle">@style/DefaultButton</item>
</style>

<style name="DefaultButton" parent="Widget.MaterialComponents.Button">
    <item name="android:textColor">@color/whatever</item>
</style>

<Button
    android:id="@+id/addChannelButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|center_horizontal"
    android:layout_margin="16dp"
    android:text="Add room" />

Why doesnt this work? It would in appcompat

// If I use Theme.MaterialComponents.Light.NoActionBar.Bridge, then it works

like image 514
urSus Avatar asked Feb 28 '26 08:02

urSus


1 Answers

You should be setting materialButtonStyle instead of buttonStyle in your theme.

like image 186
Cameron Ketcham Avatar answered Mar 03 '26 00:03

Cameron Ketcham



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!