我最近在我的应用中添加了BottomSheetDialogFragment,但是在Material Dark主题下它的背景颜色显示为白色。即使使用
android:background="?android:attr/colorBackground"
对于对话框的根布局,它仍然是白色的(但这个属性在对话框外部是有效的)。有人遇到过这个问题吗?
我最近在我的应用中添加了BottomSheetDialogFragment,但是在Material Dark主题下它的背景颜色显示为白色。即使使用
android:background="?android:attr/colorBackground"
对于对话框的根布局,它仍然是白色的(但这个属性在对话框外部是有效的)。有人遇到过这个问题吗?
bottomSheetDialogTheme
的属性控制,它默认为 Theme.Design.Light.BottomSheetDialog
。要实现黑色背景(以及白色文本、正确着色的控件等),您需要在活动主题中覆盖它:<style name="YourActivityTheme" parent="...">
<!-- ... -->
<item name="bottomSheetDialogTheme">@style/Theme.Design.BottomSheetDialog</item>
</style>
android:background="?android:attr/colorBackground"