【发布时间】:2019-04-26 10:37:46
【问题描述】:
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 扩展,我不会得到我在皮肤主题中定义的配色方案。
那么问题来了:如何在皮肤主题中定义Dialog主题?
【问题讨论】:
-
您是否在“setupDialog”覆盖方法中设置BottomSheetDialogFragment中的任何视图?
-
当然,我膨胀了 XML。我实际上是在 onCreateView 中完成的。最后,我最终将主题中的颜色复制粘贴到对话框主题中。似乎是唯一的解决方案:/
标签: android android-theme bottom-sheet material-components material-components-android