Sometimes while working in Android we need to display the layout-bounds on device. Recent Android versions do provide an action-tile to do so. But on previous versions, we had to go too deep into the Settings application. I wanted to be able to perform the switch from my computer.
ADB does provide methods to do so, but the commands are not easy to remember and also get tiresome after some time.
# We need to execute both lines to # make the layout-bounds show adb shell setprop debug.layout true adb shell service call activity 1599295570
So I made 2 files named
hide-lb.sh, which respectively show and hide the layout-bounds on our testing device.
The files are as below:
adb shell setprop debug.layout true > /dev/null 2>&1 adb shell service call activity 1599295570 > /dev/null 2>&1
adb shell setprop debug.layout false > /dev/null 2>&1 adb shell service call activity 1599295570 > /dev/null 2>&1
> /dev/null 2>&1 part at the end of each line is just so that the output of that particular command does not get displayed in our terminal as we don’t need it.
Note for Windows users: You friends need to omit the
> /dev/null 2>&1 and save these files as
You can save these files (make sure to give them
executable permission if you are on a unix-based machine) and then add their location to system’s
PATH variable. That way you can execute these from anywhere.
I do think that I would indeed make a version of this in the future where it check the current state and automatically toggle it.