siebeprojects / samples-keyboardheight

Calculates the height of a floating soft input Android keyboard
321 stars 70 forks source link

keyboardheight is error for my xiaomi mix2S-API26 #5

Open fangkeweiyou1 opened 6 years ago

derekcsm commented 5 years ago

Having the same issue, I think it's related to the top notch, and swipe navigation

truptigoqii commented 5 years ago

Having same issue with full screen gestures.

AvalonAlexXY commented 5 years ago

it is my solution :

     int topCutoutHeight = 0;

    //Solve problems caused  Android P,you can check issuses #4
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
        topCutoutHeight = getTopCutoutHeight() /*+ UiUtils.getStatusBarHeight(activity)*/;
    }

    //Solve problems caused  MIUI
    if(RomUtil.isMiui()){  //check is MIUI
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            // Whether hide navigationbar,if hide:add navigationbar height
            if(Settings.Global.getInt(activity.getContentResolver(), "force_fsg_nav_bar", 0) != 0) {
                topCutoutHeight = topCutoutHeight + UiUtils.getNavigationBarHeight(activity);
            }
        }
    }

    int keyboardHeight = screenSize.y + topCutoutHeight - rect.bottom ;