如何将BottomSheetDialogFragment
主题与其他主题结合?
我的应用程序使用主题制作皮肤。我想让BottomSheetDialogFragment
显示为圆角矩形,我通过以下方式实现:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(BottomSheetDialogFragment.STYLE_NORMAL, R.style.CustomBottomSheetDialogTheme) /* hack to make background transparent */
}
然后在
styles.xml
中:<style name="CustomBottomSheetStyle" parent="Widget.Design.BottomSheet.Modal">
<item name="android:background">@android:color/transparent</item>
</style>
<style name="CustomBottomSheetDialogTheme" parent="Theme.MaterialComponents.Light.BottomSheetDialog">
<item name="bottomSheetStyle">@style/CustomBottomSheetStyle</item>
</style>
如果我从 Theme.MaterialComponents.Light.BottomSheetDialog
扩展,我就得不到我在皮肤主题中定义的颜色方案。
所以问题是:如何在皮肤主题内定义对话框主题?