Show layout bounds from command line

Lately I found myself clicking through Android Settings menu to enable and disable “Show layout bounds” to check if views are where are supposed to be a bit too often.

Using the menu once is OK. Using the menu twice is still OK. I live by the Rule of three so when I hit the “three times threshold” I start looking for a better solution.

For me, a cli command is faster than clicking through menus, so I created a couple of aliases for my .zshrc file. Open an editor an paste these two lines in there:

alias boundson='adb shell setprop debug.layout true; adb shell service call activity 1599295570 > /dev/null'

alias boundsoff='adb shell setprop debug.layout false ; adb shell service call activity 1599295570 > /dev/null'

Restart your terminal and now you have two new commands:

  • boundson
  • boundsoff

to turn ON and OFF those layout bounds 👍