我正在尝试在多窗格应用程序中实现一个BottomSheetDialogFragment
。它现在看起来是这样的:
----------------------------------------
| | |
| | |
| Fragment | Fragment |
| | |
| | |
----------------------------------------
| BottomSheetDialogFragment |
----------------------------------------
但我想实现的是:
----------------------------------------
| | |
| | |
| Fragment | Fragment |
| | |
| | |
|------------------------| |
| | |
| BottomSheetDialog | |
----------------------------------------
我的问题是:可能用BottomSheetDialogFragment
来实现吗?或者我需要一个不同的方法?如果可能的话,你们能为我指出如何实现这个目标的方向吗?谢谢!
2条答案
按热度按时间vmpqdwk31#
当我在开发一个带有底部表单的平板电脑解决方案时,我遇到了与您相同的问题。对我来说,解决方案是在Fragment 1中添加一个子片段。该子片段是一个普通的Fragment,使用BottomSheetBehaviour类来建立与BottomSheetDialogFragment相同的结果。
请务必将BottomSheetBehaviour视图放置在CoordinatorLayout中。
然后将下面的Kotlin代码放到你的代码片段中(在这个例子中,我使用了带有绑定的布局)。
然后,您可以使用
bottomSheetBehaviour.addBottomSheetCallback
为底部表单添加状态和幻灯片更改侦听器。我从这一页找到了灵感:https://www.androidhive.info/2017/12/android-working-with-bottom-sheet/
nkkqxpd92#
您可以尝试使用
RelativeLayout
来实现您想要的功能: