WebJul 19, 2024 · 23 Answers Sorted by: 207 Try below code: Resources resources = context.getResources (); int resourceId = resources.getIdentifier ("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { return resources.getDimensionPixelSize (resourceId); } return 0; Share Follow answered Nov 28, 2013 at 11:03 Sanket 3,054 1 … WebJun 12, 2012 · In my limited testing so far, getRealMetrics () gives the correct results even on 4.0 devices, where you would expect it to crash. Also noteworthy is that getRealMetrics returns the correct DPI, where the other methods for getting a DisplayMetrics can return bogus data. (With the other methods, my S4 was claiming to be an mpdi device!) – benkc
Deprecations Android Developers
WebFeb 14, 2013 · Not to be too nit-picky, but your return statement might be a little more readable as: return (realWidth > displayWidth) (realHeight > displayHeight) One note: if you do this from a service, and the service accidentally starts while the device is in full screen (i.e Youtube etc..), you'll get the wrong result. Web您是对的,它显示了应用程序屏幕的分辨率,因此您得到了差异。使用getRealMetrics()代替getMetrics()。 您可以使用以下代码获得设备的实际屏幕大小 dj rafa russo
[Solved]-display.getRealMetrics() is deprecated-kotlin
WebgetRealMetrics(DisplayMetrics outMetrics) This method was deprecated in API level 31. Use WindowManager#getCurrentWindowMetrics() to identify the current size of the activity … WebgetRealMetrics method in android.view.Display Best Java code snippets using android.view. Display.getRealMetrics (Showing top 20 results out of 819) android.view … WebApr 19, 2016 · 3. Since Android N introduces split screen, the window size of your app can be half of the original. I found that getActivity ().getWindowManager ().getDefaultDisplay ().getMetrics (metrics); no longer always returns the actual device screen size anymore because in split screen mode the display's height will be your app's window height instead. جنيه 1