Как поменять цвет диалога?
Есть диалог BottomSheetDialogFragment
и тема Theme.Material3.Light.NoActionBar
. Нужно сделать задний фон диалога таким же как у активити.
Гайд предлагает изменить backgroundTint
у Widget.Material3.BottomSheet.Modal
, который по умолчанию ссылается на colorSurface
. В теме android:colorBackground
и colorSurface
одинаковые. Итоговый цвет диалога будто смешивается с другим цветом и отличается от целевого. Вероятно потому что это tint
.
В стандартной теме также есть background=@null
, но его изменение ничего не делает. Полагаю причина в комментарии к backgroundTint
. Но что такое shape theming
и как его отключить так и не понял.
<!-- Background color used by the BottomSheetBehavior background drawable when shape theming is enabled.
Accepts a ColorStateList or ColorInt.
If shape theming is not enabled, android:background should instead be utilized
to set the background resource. -->
<attr name="backgroundTint"/>
<color name="md_theme_light_background">#FFFBFE</color>
<color name="md_theme_light_surface">#FFFBFE</color>
<style name="Theme.Andy" parent="Theme.Material3.Light.NoActionBar">
<item name="android:colorBackground">@color/md_theme_light_background</item>
<item name="colorSurface">@color/md_theme_light_surface</item>
<item name="android:navigationBarColor">?attr/colorSurface</item>
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
<item name="bottomSheetDialogTheme">@style/App.ThemeOverlay.Material3.BottomSheetDialog</item>
</style>
<style name="App.ThemeOverlay.Material3.BottomSheetDialog" parent="ThemeOverlay.Material3.BottomSheetDialog">
<item name="android:windowIsFloating">false</item>
<item name="android:windowSoftInputMode">adjustResize</item>
<item name="bottomSheetStyle">@style/App.Widget.Material3.BottomSheet</item>
</style>
<style name="App.Widget.Material3.BottomSheet" parent="Widget.Material3.BottomSheet.Modal">
<item name="shapeAppearanceOverlay">@style/App.ShapeAppearance.Material3.Corner.TopRounded</item>
</style>
Источник: Stack Overflow на русском