DSAppTeam / PanelSwitchHelper

:heavy_check_mark: A framework that helps the keyboard smoothly transition to the function panel 一个帮助键盘平稳过渡到功能面板的框架,支持动画无缝衔接,支持 activity/fragment/dialog/dialogFragment/popupWindow 容器,支持IM/直播/视频播放/信息流评论等场景,支持全屏模式。
Apache License 2.0
2.38k stars 283 forks source link

关于此框架在BottomSheetDialogFragment使用时,华为手机底部虚拟按键弹出与隐藏时输入框位置不贴键盘 #106

Closed MrHuangZW closed 3 years ago

MrHuangZW commented 3 years ago

Androidx版本:否 PanelSwitchHelper版本:v1.3.10 手机型号: 华为 CAZ-TL 10 手机系统版本: Android 7.0 问题描述:在BottomSheetDialogFragment使用时,首次当弹出键盘时,输入框紧贴键盘,但接下来底部虚拟按键弹出与隐藏时输入框位置不贴键盘,

YummyLau commented 3 years ago

@MrHuangZW 不支持 BottomSheetDialogFragment。

YummyLau commented 3 years ago

可以参考 68 因为控制面板需要填充满屏幕。使用其他dialog或者fragment都可以支持。

MrHuangZW commented 3 years ago

我这边试过还是不行,而且我们ui是要dialog不全屏的,下面附上代码 public void onStart() { super.onStart(); Dialog dialog = getDialog(); if (dialog != null) { //设置点击外部可消失 dialog.setCanceledOnTouchOutside(true); //设置使软键盘弹出的时候dialog不会被顶起 Window win = dialog.getWindow(); dialog.setOnKeyListener(this); WindowManager.LayoutParams params = dialog.getWindow().getAttributes(); win.setSoftInputMode(params.SOFT_INPUT_ADJUST_NOTHING); //这里设置dialog的进出动画 win.setWindowAnimations(R.style.DialogBottomAnim); params.gravity = Gravity.BOTTOM; // 使用ViewGroup.LayoutParams,以便Dialog 宽度充满整个屏幕 params.width = ViewGroup.LayoutParams.MATCH_PARENT; params.height = ViewGroup.LayoutParams.MATCH_PARENT; dialog.getWindow().setAttributes(params);

        dialog.getWindow().setBackgroundDrawable(new ColorDrawable());
        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 mBottomSheetBehavior = (BottomSheetBehavior) behavior;
                //设置高度
                int height = Screen.getHeight(getContext()) - StatusBarUtil.getStatusBarHeight(getContext()) ;
                mBottomSheetBehavior.setPeekHeight(height);
                parent.setBackgroundColor(Color.TRANSPARENT);
            }
        });
    }
}
YummyLau commented 3 years ago

请参考demo dialog