【发布时间】:2019-02-21 02:14:55
【问题描述】:
我正在尝试从视频列表中启动 BottomSheetDialogFragment,一旦打开,就会播放视频,但是我希望允许用户在 BottomSheetDialogFragment 打开时从列表中选择其他视频。
我尝试了什么:
<style name="CustomBottomSheetDialogTheme" parent="Theme.Design.Light.BottomSheetDialog">
<item name="bottomSheetStyle">@style/CustomBottomSheetStyle</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:colorBackground">@android:color/transparent</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:backgroundDimAmount">0</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
</style>
<style name="CustomBottomSheetStyle" parent="Widget.Design.BottomSheet.Modal">
<item name="android:background">@android:color/transparent</item>
</style>
和:
@SuppressLint("RestrictedApi")
override fun setupDialog(dialog: Dialog?, style: Int) {
super.setupDialog(dialog, style)
dialog?.window?.setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
dialog?.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
dialog?.setCanceledOnTouchOutside(false)
dialog?.setCancelable(false)
}
以上所有内容都在 DialogFragment 中有效,但在 BottomSheetDialogFragment 中无效。
【问题讨论】:
-
不确定
BottomSheetDialogFragment但您可以使用Layout和android.support.design.widget.BottomSheetBehavior实现类似的效果.. -
您找到解决方案了吗?
-
@elementstyle 是的,我做到了。我没有显示底部工作表,而是使用了 fragmentManager “add”方法。这对我有用,因为我有一个活动多片段应用程序。
-
我回答这个问题,请查看此链接:stackoverflow.com/a/58689894/4519936
标签: android bottom-sheet dialogfragment