generally get screen size, but do not include virtual function height
/**@return*/publicint getnohasvirtualkey () { int height = getwindowmanager (). Getdefaultdisplay (). GetHeight (); return height;}
But today we test to find I said your WebView interface has a problem ah how to a blank, I see the blank phone is the kind of Huawei has a soft keyboard
The height we get from this method does not include the height of the virtual keyboard
Gets the overall screen height that contains the virtual key through reflection
/*** Through reflection, get the overall screen height containing the virtual key *@return */Private intGethasvirtualkey () {intDPI = 0; Display Display=Getwindowmanager (). Getdefaultdisplay (); Displaymetrics DM=NewDisplaymetrics (); @SuppressWarnings ("Rawtypes") Class C; Try{C= Class.forName ("Android.view.Display"); @SuppressWarnings ("Unchecked") Method Method= C.getmethod ("Getrealmetrics", Displaymetrics.class); Method.invoke (display, DM); DPI=Dm.heightpixels; } Catch(Exception e) {e.printstacktrace (); } returndpi;}
the height of the virtual key
Gethasvirtualkey ()-Getnohasvirtualkey ()
Hide Virtual keys
if(Build.VERSION.SDK_INT >=Build.version_codes. KITKAT) {(Activity) context). GetWindow (). Getdecorview (). Setsystemuivisibility (View.system_ui_flag_layout_ STABLE|view.system_ui_flag_layout_hide_navigation|View.system_ui_flag_layout_fullscreen|view.system_ui_flag_hide_navigation|View.system_ui_flag_fullscreen| view.system_ui_flag_immersive);//API19}Else{(Activity) context). GetWindow (). Getdecorview (). Setsystemuivisibility (View.system_ui_flag_layout_sta BLE|view.system_ui_flag_layout_hide_navigation|View.system_ui_flag_layout_fullscreen|view.system_ui_flag_hide_navigation|view.system_ui_flag_fullscreen);}
All right, that's it.
Android gets the actual height of the screen with the display height to determine if the Android device has a virtual function key