Android部分流海屏判斷方法

2021-09-03 07:02:28 字數 1074 閱讀 6753

/**

* 判斷當前裝置是否為流海屏

* * @return

*/public static boolean hasnotch(activity act)

/** * android p 是否流海屏

* * @param act

* @return

*/public static boolean hasnotchp(activity act) }}

return false;

} else

}/**

* 華為是否有流海屏

* * @param context context

* @return 是否有流海屏

*/public static boolean hasnotchathuawei(context context) catch (classnotfoundexception e) catch (nosuchmethodexception e) catch (exception e) finally

}/**

* 小公尺是否流海屏

* * @param act

* @return

*/public static boolean hasnotchatxiaomi(activity act) else

}/**

* oppo是否有流海屏

* * @param context context

* @return 是否有流海屏

*/public static boolean hasnotchatoppo(context context)

/** * vivo是否有流海屏

* * @param context context

* @return 是否有流海屏

*/public static boolean hasnotchatvivo(context context) catch (classnotfoundexception e) catch (nosuchmethodexception e) catch (exception e) finally

}

流海屏 異形屏判斷 適配

public static boolean hasnotch activity act 華為是否有流海屏 param context context return 是否有流海屏 public static boolean hasnotchathuawei context context catch ...

android 橫屏豎屏判斷

方法1 displaymetrics dm new displaymetrics getwindowmanager getdefaultdisplay getmetrics dm int width dm.widthpixels int height dm.heightpixels 方法2 if t...

android判斷手機螢幕橫豎屏

在乙個activity顯示中判斷當前螢幕橫豎屏情況有幾種方法 configuration configuration getresources getconfiguration if configuration.orientation configuration.orientation landsc...