Recently I switched to using com.google.android.material:material:1.0.0
for app theme.
In addition to set colorPrimary
,colorPrimaryDark
and colorAccent
and using MaterialButton
with Widget.MaterialComponents.Button
style, buttons in activity/fragment and bottomSheetFragment are different in colors!
in Activity/Fragment is OK. but in BottomSheet has a different color (green).
Define a new style for BottomSheetDialogFragment:
<style name="MyBottomSheetStyle" parent="@style/Theme.MaterialComponents.Light.BottomSheetDialog">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
</style>
You can apply it via app theme by setting it as bottomSheetDialogTheme
in main app style:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
...
<item name="bottomSheetDialogTheme">@style/MyBottomSheetStyle</item>
</style>
or override getTheme()
of in your bottom-sheet class.
override fun getTheme(): Int = R.style.MyBottomSheetStyle
If you choose second one, It's better to use a base class and implement getTheme()
on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With