How to easily “Show Layout bounds” for Android debugging?

后端 未结 5 1848
伪装坚强ぢ
伪装坚强ぢ 2021-02-01 21:31

I want to watch the layout of App without boring tap and tap.


I tried adb shell setprop debug.layout true but didn\'t work unless re

相关标签:
5条回答
  • 2021-02-01 22:04

    You don't need to start the settings app. Just exit your app, set the property, and start your app.

    adb shell am force-stop com.company.appname ; adb shell setprop debug.layout true ; adb shell monkey -p com.company.appname -c android.intent.category.LAUNCHER 1
    
    0 讨论(0)
  • 2021-02-01 22:08

    Here is my fish shell function that will also help you to choose from multiple devices with fzf. save it in ~/.config/fish.functions/ and use it like this:

    and if you have more than one device it will prompt to select one with fzf

    0 讨论(0)
  • 2021-02-01 22:15

    This tool works fine. You need to install groovy before launch this program.

    https://github.com/dhelleberg/android-scripts

    0 讨论(0)
  • 2021-02-01 22:16

    This works for me:

    adb shell setprop debug.layout true
    adb shell service call activity 1599295570
    

    After we have enabled Show layout bounds using adb shell setprop debug.layout true, we have to poke the SystemProperties to see the changes as Show layout bounds QS Tiles does:

    @Override
    public void onClick() {
        setIsEnabled(getQsTile().getState() == Tile.STATE_INACTIVE);
        new DevelopmentSettings.SystemPropPoker().execute(); // Settings app magic
        refresh();
    }
    

    Here's the original method from AOSP source:

    public static class SystemPropPoker extends AsyncTask<Void, Void, Void> {
        @Override
        protected Void doInBackground(Void... params) {
            String[] services = ServiceManager.listServices();
            for (String service : services) {
                IBinder obj = ServiceManager.checkService(service);
                if (obj != null) {
                    Parcel data = Parcel.obtain();
                    try {
                        obj.transact(IBinder.SYSPROPS_TRANSACTION, data, null, 0);
                    } catch (RemoteException e) {
                    } catch (Exception e) {
                        Log.i(TAG, "Someone wrote a bad service '" + service
                                + "' that doesn't like to be poked: " + e);
                    }
                    data.recycle();
                }
            }
            return null;
        }
    }
    

    The number 1599295570 is called SYSPROPS_TRANSACTION

    Reference: https://github.com/dhelleberg/android-scripts/blob/master/src/devtools.groovy

    UPDATED: I created this app to add many developer toggle to the quick settings for Android 7.0+

    0 讨论(0)
  • 2021-02-01 22:25

    I found a DevelopQuickSetting tool can easily make this. https://github.com/kyze8439690/DevelopQuickSetting

    and the core code translate to adb shel is:

    adb shell setprop debug.layout true
    adb shell service check SurfaceFlinger
    
    0 讨论(0)
提交回复
热议问题