Skullper
Skullper

Reputation: 775

MaterialButton style shapeAppearance not working

I'm struggling to set the right style for my button in the project. I don't know why shapeAppearance not working. Even if I use only cornerSize it's not working.

I have a base style for a button:

<style name="SnButton" parent="Widget.MaterialComponents.Button.UnelevatedButton">
    <item name="shapeAppearance">@style/MyShapeAppearance</item>
    <item name="backgroundTint">@null</item>
</style>

This is my shape appearance for a button:

<style name="MyShapeAppearance" parent="ShapeAppearance.MaterialComponents.SmallComponent">
    <item name="cornerFamily">rounded</item>
    <item name="cornerSize">2dp</item>
</style>

This is my base theme: Theme.MaterialComponents.Light.NoActionBar.Bridge

What should I do to force shapeAppearance work in my case? Or at least cornerSize?

Upvotes: 1

Views: 985

Answers (1)

Skullper
Skullper

Reputation: 775

I figured out why style was not working!

The problem was in the way I set the color for the button. I've used android:background, but backgroundTint must be used.

Upvotes: 6

Related Questions