Android 全屏下页碎片

Android 全屏下页碎片,android,android-fragments,Android,Android Fragments,我一直试图在android中实现底部工作表片段,但在默认情况下无法将其扩展到全屏。我甚至试着将它的状态设置为状态 public void setupDialog(Dialog dialog, int style) { super.setupDialog(dialog, style); View v = View.inflate(getContext(), R.layout.fragment_my_bottom_sheet_dialog, null); d

我一直试图在android中实现底部工作表片段,但在默认情况下无法将其扩展到全屏。我甚至试着将它的状态设置为状态

public void setupDialog(Dialog dialog, int style) {
       super.setupDialog(dialog, style);
       View v = View.inflate(getContext(), R.layout.fragment_my_bottom_sheet_dialog, null);
       dialog.setContentView(v);

       CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) v.getParent()).getLayoutParams();
       CoordinatorLayout.Behavior behavior = params.getBehavior();

       if (behavior != null && behavior instanceof BottomSheetBehavior) {
           Log.d(TAG, "Inside if");
           ((BottomSheetBehavior) behavior).setState(BottomSheetBehavior.STATE_EXPANDED);
           ((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetCallback);
       }
   }
但这会弄乱从底部向上浮动的板材动画。我正在尝试创建一个全屏模式的底部工作表和一个带有关闭(X)按钮的工具栏,如下所示


如果有人能帮我,我将不胜感激。

我能确定的是,您需要一个向上滑动的面板来执行设置。我强烈建议你使用乌马诺图书馆。 它有两个孩子。一个用于活动/片段,另一个用于面板

<com.sothree.slidinguppanel.SlidingUpPanelLayout
    xmlns:sothree="http://schemas.android.com/apk/res-auto"
    android:id="@+id/sliding_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="bottom"
    sothree:umanoPanelHeight="68dp"
    sothree:umanoShadowHeight="4dp">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="Main Content"
        android:textSize="16sp" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center|top"
        android:text="The Awesome Sliding Up Panel"
        android:textSize="16sp" />
</com.sothree.slidinguppanel.SlidingUpPanelLayout>


我只是想尝试一下,问题是我想用一个单独的活动/片段来实现它,因为我将有一些局部变量和计算,我想与面板隔离。没有问题。在面板布局中,只需添加一个框架布局。现在,在活动的FrameLayout中使用FragmentManager制作片段、片段布局并将其充气。这样,您的面板逻辑将在单独的类中。如果您发现任何困难,我将更新代码。但如果你明白我想说的话,那么这就很好了我试过了,但遇到了另一个问题。我想在片段中添加一个单独的工具栏,带有菜单项和关闭按钮,并避免重置活动工具栏。你知道我能做什么吗?但这会弄乱床单从底部向上浮动的动画。你的意思是当碎片被附着时,底部的薄片会从下到上进行动画制作吗?我不确定你是否仍在寻找答案,但效果很好