I want to know what is the size of the navigation bar in pixel using ADB.
adb shell wm size gives the complete screen size instead of only the navigation bar.
Is there any way to get it?
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It only takes a minute to sign up.Sign up to join this community
Enter this one-liner:
adb shell dumpsys window windows| sed -n '/Window .*NavigationBar.*:/,/Window .*:/p'| grep 'Requested'
Alternatively, if you don't have Linux/Mac, try this:
adb shell dumpsys window windows | toybox sed -n '/Window .*NavigationBar.*:/,/Window .*:/p'| grep 'Requested'
What's happening in that one liner is this:
we use dumpsys to output all the details of all the windows displayed on the screen (irrespective of the screen on or off)
we filter the content using sed to show only those lines which have information about Navigation Bar
we grep the information we need.
You can alternatively try grepping for
grep mSystemDecorRect. I don't know which one is more reliable in all circumstances.
Expected output example:
Requested w=1080 h=126 mLayoutSeq=10835 # if 'mSystemDecorRect' was grepped, then: mSystemDecorRect=[0,0][1080,126] mLastClipRect=[0,0][1080,126]
w: width, h: height, of your navigation bar respectively.
Note: for some reason if the one-liner fails to work or gives unexpected output, filter it like this. Get the dump using that first dumpsys command, then find the entry for your NavigationBar, and within that, look for the size.
Tested on OnePlus 6 running Android 10.
Credits: Fiximan of Unix & Linux for sed command.