How to handle notch(display cutout) in android API lower than 28?

前端 未结 4 1243
你的背包
你的背包 2020-12-16 14:12

Android added notch support on API 28, but how to handle it on devices running API 27 (Honor 10, Huawei P20, etc.) ?

I was trying to use DisplayCutoutCompat<

4条回答
  •  醉酒成梦
    2020-12-16 15:04

    Google provided notch related APIs in Android P. Devices with notch and API version lower than P implemented their own notch APIs.You can consult the APIs from device specified documentation.

    Also I did not see creation of DisplayCutoutCompat instance in official documentation, but you can create DisplayCutout as follow:

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
                DisplayCutout displayCutout = getWindow().getDecorView().getRootWindowInsets().getDisplayCutout();
    }
    

提交回复
热议问题