1

I want to know what is the size of the navigation bar in pixel using ADB.

Using adb shell wm size gives the complete screen size instead of only the navigation bar.

Is there any way to get it?

0
2

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:

  1. we use dumpsys to output all the details of all the windows displayed on the screen (irrespective of the screen on or off)

  2. we filter the content using sed to show only those lines which have information about Navigation Bar

  3. 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.

1
  • 1
    Thanks. Also possible to get using: adb shell dumpsys SurfaceFlinger | grep -i “Navigation”
    – Spyder
    Jul 20 '20 at 16:32
1

on my device(OnePlus 3 running Android 9), it should change NavigationBar to StatusBar

➜  adb shell dumpsys window windows| sed -n '/Window .*StatusBar.*:/,/Window .*:/p'| grep 'Requested'

get this

Requested w=1080 h=63 mLayoutSeq=3640

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.