I made a system overlay window that always stays on top of other apps. The width of the screen is 'MATCH_PARENT' and I want from the height to cover a certain area of the screen but my problem is that the height won't be same on different screens.
Here is my code:
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
1500,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN |
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSPARENT);
How can can I make that 1500p be the same on different screens? Thanks.
My problem was solved by tiny sunlight:
(int)(getResources().getDisplayMetrics().heightPixels* 0.8f)
you have to replace the desired dimensions parameter with this and adjust the 0,8F to the desired measurements.