Jacksgong / JKeyboardPanelSwitch

For resolve the layout conflict when keybord & panel are switching (Android键盘面板冲突 布局闪动处理方案)
Apache License 2.0
4.18k stars 684 forks source link

Android9.0 刘海屏机型 无法触发onKeyboardShowing回调 #99

Closed farsunset closed 5 years ago

farsunset commented 5 years ago

手机是 一加6 系统为Android9 1.注入回调 KeyboardUtil.attach((Activity)getContext(), rootPanel,this); 2.输入框获得焦点 弹出键盘,这个时候onKeyboardShowing并没有触发

farsunset commented 5 years ago

并且 点击swtich的时候 显示panel 关闭键盘,但是panel会先显示出来,这个时候键盘还没有完全关闭,导致panel被顶上去了,会造成闪烁的现象

lic2050 commented 5 years ago

你这个是透明状态栏吗?我只要设置透明状态栏就会有这个问题

farsunset commented 5 years ago

你这个是透明状态栏吗?我只要设置透明状态栏就会有这个问题

我的不是透明状态栏

jhwing commented 5 years ago

这个问题是由这句话导致的,可是我是在不知道这句话有什么用?我在正常的手机上测试了各种情况代码也走不进这个判断。只有在9.0系统,手机应该是默认开启了“应用全屏显示”,比如我测试时用的华为手机,导致 phoneDisplayHeight 永远等于actionBarOverlayLayoutHeight ,所以后面的判断isKeyboardShowing永远等于false。那这句话可不可以去掉,作者在实现这里的时候是遇到了什么问题要加上这个判断?

    final int phoneDisplayHeight = contentView.getResources().getDisplayMetrics().heightPixels;
    if (!isTranslucentStatus &&
            phoneDisplayHeight == actionBarOverlayLayoutHeight) {
        // no space to settle down the status bar, switch to fullscreen,
        // only in the case of paused and opened the fullscreen page.
        Log.w(TAG, String.format("skip the keyboard status calculate, the current" +
                        " activity is paused. and phone-display-height %d," +
                        " root-height+actionbar-height %d", phoneDisplayHeight,
                actionBarOverlayLayoutHeight));
        return;

    }
wangshaolei commented 5 years ago

@jhwing @Jacksgong 我这儿也有会员反馈了,是mate pro20。我这边 目前 机型不多,还没具体测试。你这儿有什么解决方案了吗

wangshaolei commented 5 years ago

@jhwing @Jacksgong 怀疑应该是屏幕高度加上刘海适配高度,系统可能改了什么

huangjie21 commented 5 years ago

目前我也是遇到了这个问题。设置了 isTranslucentStatus true。就不会闪,但是状态栏不是沉浸式了。如果设为 isTranslucentStatus false 就会闪动。也是华为mate pro 20 ,在模拟器上又测不出是什么问题。是不是全面屏适配的问题呢?

wangshaolei commented 5 years ago

目前我也是遇到了这个问题。设置了 isTranslucentStatus true。就不会闪,但是状态栏不是沉浸式了。如果设为 isTranslucentStatus false 就会闪动。也是华为mate pro 20 ,在模拟器上又测不出是什么问题。是不是全面屏适配的问题呢?

我并没有translucent,正常6.0 light mode

androidWht commented 5 years ago

这个问题还没有修复吗?

wangshaolei commented 5 years ago

@androidWht 正在持续关注

kinkenrin commented 5 years ago

删除KeyboardUtil中的这段代码 即可/*final int phoneDisplayHeight = contentView.getResources() .getDisplayMetrics().heightPixels; if (!isTranslucentStatus && phoneDisplayHeight == actionBarOverlayLayoutHeight) { // no space to settle down the status bar, switch to fullscreen, // only in the case of paused and opened the fullscreen page. Log.w(TAG, String.format("skip the keyboard status calculate, the current"

farsunset commented 5 years ago

删除KeyboardUtil中的这段代码 即可/final int phoneDisplayHeight = contentView.getResources() .getDisplayMetrics().heightPixels; if (!isTranslucentStatus && phoneDisplayHeight == actionBarOverlayLayoutHeight) { // no space to settle down the status bar, switch to fullscreen, // only in the case of paused and opened the fullscreen page. Log.w(TAG, String.format("skip the keyboard status calculate, the current" + " activity is paused. and phone-display-height %d," + " root-height+actionbar-height %d", phoneDisplayHeight, actionBarOverlayLayoutHeight)); return; }/ 看注释作者是为了兼容全屏才写这段代码的,如果项目里没有用到fullscreen 注释掉这段代码就行了

老哥,稳不稳? 会不会在其他android版本和style情况下又副作用

kinkenrin commented 5 years ago

删除KeyboardUtil中的这段代码 即可/final int phoneDisplayHeight = contentView.getResources() .getDisplayMetrics().heightPixels; if (!isTranslucentStatus && phoneDisplayHeight == actionBarOverlayLayoutHeight) { // no space to settle down the status bar, switch to fullscreen, // only in the case of paused and opened the fullscreen page. Log.w(TAG, String.format("skip the keyboard status calculate, the current" + " activity is paused. and phone-display-height %d," + " root-height+actionbar-height %d", phoneDisplayHeight, actionBarOverlayLayoutHeight)); return; }/ 看注释作者是为了兼容全屏才写这段代码的,如果项目里没有用到fullscreen 注释掉这段代码就行了

老哥,稳不稳? 会不会在其他android版本和style情况下又副作用

看源码keyboardShowingListener就在这段代码下面执行 如果这里return了 keyboardShowingListener铁定是没有回调的,所以个人觉得正常应该没问题

farsunset commented 5 years ago

问题暂时解决了,不知道是作者当时的bug还是其他原因,修改如下 KeyboardUtil.java 407行添加一个else分支 else { maxOverlayLayoutHeight = phoneDisplayHeight; }

另外5楼老哥的方法同样有效,不知道作者当初的思路是怎么样的

wangshaolei commented 5 years ago

@farsunset 看注释像是解决全面屏的一个问题,fullscreen,可能是写出bug了,但是这个bug奇怪就在于部分手机出现了,和部分手机兼容 有关。

kinkenrin commented 5 years ago

问题暂时解决了,不知道是作者当时的bug还是其他原因,修改如下 KeyboardUtil.java 407行添加一个else分支 else { maxOverlayLayoutHeight = phoneDisplayHeight; }

另外5楼老哥的方法同样有效,不知道作者当初的思路是怎么样的

你这招在mate20 pro上依旧会闪烁

farsunset commented 5 years ago

问题暂时解决了,不知道是作者当时的bug还是其他原因,修改如下 KeyboardUtil.java 407行添加一个else分支 else { maxOverlayLayoutHeight = phoneDisplayHeight; } 另外5楼老哥的方法同样有效,不知道作者当初的思路是怎么样的

你这招在mate20 pro上依旧会闪烁 我的一加6上倒是可以,算了我还是采用了5楼的方式

jhwing commented 5 years ago

删除KeyboardUtil中的这段代码 即可/final int phoneDisplayHeight = contentView.getResources() .getDisplayMetrics().heightPixels; if (!isTranslucentStatus && phoneDisplayHeight == actionBarOverlayLayoutHeight) { // no space to settle down the status bar, switch to fullscreen, // only in the case of paused and opened the fullscreen page. Log.w(TAG, String.format("skip the keyboard status calculate, the current" + " activity is paused. and phone-display-height %d," + " root-height+actionbar-height %d", phoneDisplayHeight, actionBarOverlayLayoutHeight)); return; }/ 看注释作者是为了兼容全屏才写这段代码的,如果项目里没有用到fullscreen 注释掉这段代码就行了

老哥,稳不稳? 会不会在其他android版本和style情况下又副作用

看源码keyboardShowingListener就在这段代码下面执行 如果这里return了 keyboardShowingListener铁定是没有回调的,所以个人觉得正常应该没问题

注释掉这部分代码目前没有发现问题

jxj2118 commented 5 years ago

删除KeyboardUtil中的这段代码 即可/final int phoneDisplayHeight = contentView.getResources() .getDisplayMetrics().heightPixels; if (!isTranslucentStatus && phoneDisplayHeight == actionBarOverlayLayoutHeight) { // no space to settle down the status bar, switch to fullscreen, // only in the case of paused and opened the fullscreen page. Log.w(TAG, String.format("skip the keyboard status calculate, the current" + " activity is paused. and phone-display-height %d," + " root-height+actionbar-height %d", phoneDisplayHeight, actionBarOverlayLayoutHeight)); return; }/ 看注释作者是为了兼容全屏才写这段代码的,如果项目里没有用到fullscreen 注释掉这段代码就行了

老哥,稳不稳? 会不会在其他android版本和style情况下又副作用

看源码keyboardShowingListener就在这段代码下面执行 如果这里return了 keyboardShowingListener铁定是没有回调的,所以个人觉得正常应该没问题

注释掉这部分代码目前没有发现问题

小米9上 两个方法都不行 头大

farsunset commented 5 years ago

这个项目看样子烂尾了,期待出现另一个大神再造轮子