gpt4 book ai didi

android - 全屏底页 fragment

转载 作者:太空狗 更新时间:2023-10-29 13:10:48 26 4
gpt4 key购买 nike

我一直在尝试在 android 中实现底部工作表 fragment ,但默认情况下无法将其缩放到全屏。我什至尝试将其状态设置为 STATE_EXPANDED

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);
}
}

但这弄乱了床单从底部向上 float 的动画。我正在尝试创建一个带有全屏和工具栏的模式底部工作表,带有这样的关闭(X)按钮

Full screen bottom sheet

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

最佳答案

我可以确定的是,您需要一个向上滑动面板来执行设置。我强烈建议您使用 umano 的 Android Sliding Up Panel图书馆。它有2个 child 。一个用于 Activity/fragment ,另一个用于面板。

<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>

关于android - 全屏底页 fragment ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41313375/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com