美文网首页BottomSheet
BottomSheetDialogFragment 全屏显示

BottomSheetDialogFragment 全屏显示

作者: yyg | 来源:发表于2018-07-02 13:47 被阅读179次
     @Override
        public void onStart() {
            super.onStart();
            Dialog dialog = getDialog();
            if (dialog != null) {
                View bottomSheet = dialog.findViewById(R.id.design_bottom_sheet);
                bottomSheet.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT; //可以写入自己想要的高度
            }
            final View view = getView();
            view.post(new Runnable() {
                @Override
                public void run() {
                    View parent = (View) view.getParent();
                    CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) (parent).getLayoutParams();
                    CoordinatorLayout.Behavior behavior = params.getBehavior();
                    BottomSheetBehavior bottomSheetBehavior = (BottomSheetBehavior) behavior;
                    bottomSheetBehavior.setPeekHeight(view.getMeasuredHeight());
                    parent.setBackgroundColor(Color.WHITE);
                }
            });
        }
    

    相关文章

      网友评论

        本文标题:BottomSheetDialogFragment 全屏显示

        本文链接:https://www.haomeiwen.com/subject/lyxluftx.html