android Navigation Bar hiding and persantage of usable screen overlap
Asked Answered
S

1

3

My problem is about persantage of usable screen . My application working well normally but ı assume that if ı change dimension of screen (for example galaxy s8+) it is down.

this is how is working fine

enter image description here strong text

and this is the wrong one

enter image description here

the problem related with NavigationBar. I tried to set MACHPARENT params and normally I use programmatically DisplayMetrics metrics = this.getResources().getDisplayMetrics(); width = metrics.widthPixels; height = metrics.heightPixels - Utils.getStatusBarHeight(getContext()); this code. But it is not working in Galaxy s8+ when I hide navigationBar. Does anyone can help me what is my fold?

edit. I mean height of my screen doesnt work.

Submissive answered 20/8, 2017 at 1:2 Comment(2)
did you ever find the answer to this question? I am running into the same issue. The S8 nav bar messes up my app's measurements. The UI doesn't look right at all anymore.Spearman
please post here if u've found any solution to this problemVallejo
H
3

I had the same problem and could solve this with the decorview:

    //Get the correct screen size even if the device has a hideable navigation bar (e.g. the Samsung Galaxy S8)
    View decorView = getWindow().getDecorView(); //if you use this in a fragment, use getActivity before getWindow()
    Rect r = new Rect();
    decorView.getWindowVisibleDisplayFrame(r);
    int screenHeight = r.bottom; // =2220 on S8 with hidden NavBar and =2076 with enabled NavBar
    int screenWidth = r.right; // =1080 on S8
Henrietta answered 19/6, 2018 at 9:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.