[Android] 如何理解dumpsys activity打印出来的view的信息

有时候,我们用dumpsys activity all [package name]来查看当前app的一些view信息,其中有:

View Hierarchy:
  DecorView@1f69f7a[LiveVideoViewerActivity]
    android.widget.LinearLayout{cf5432b V.E...... .......D 0,0-1080,1920}
      android.view.ViewStub{d26e388 G.E...... ......I. 0,0-0,0 #1020186 android:id/action_mode_bar_stub}
      android.widget.FrameLayout{6128121 V.E...... .......D 0,60-1080,1920}

类似“{cf5432b V.E…… …….D 0,0-1080,1920}”的信息,实际含义是什么呢?

这里dump出来的信息,其实是通过view.toString()方法打印出来的,这里贴一下代码,备查:

public String toString() {
    StringBuilder out = new StringBuilder(128);
    out.append(getClass().getName());
    out.append('{');
    out.append(Integer.toHexString(System.identityHashCode(this)));
    out.append(' ');
    switch (mViewFlags&VISIBILITY_MASK) {
        case VISIBLE: out.append('V'); break;
        case INVISIBLE: out.append('I'); break;
        case GONE: out.append('G'); break;
        default: out.append('.'); break;
    }
    out.append((mViewFlags & FOCUSABLE) == FOCUSABLE ? 'F' : '.');
    out.append((mViewFlags&ENABLED_MASK) == ENABLED ? 'E' : '.');
    out.append((mViewFlags&DRAW_MASK) == WILL_NOT_DRAW ? '.' : 'D');
    out.append((mViewFlags&SCROLLBARS_HORIZONTAL) != 0 ? 'H' : '.');
    out.append((mViewFlags&SCROLLBARS_VERTICAL) != 0 ? 'V' : '.');
    out.append((mViewFlags&CLICKABLE) != 0 ? 'C' : '.');
    out.append((mViewFlags&LONG_CLICKABLE) != 0 ? 'L' : '.');
    out.append((mViewFlags&CONTEXT_CLICKABLE) != 0 ? 'X' : '.');
    out.append(' ');
    out.append((mPrivateFlags&PFLAG_IS_ROOT_NAMESPACE) != 0 ? 'R' : '.');
    out.append((mPrivateFlags&PFLAG_FOCUSED) != 0 ? 'F' : '.');
    out.append((mPrivateFlags&PFLAG_SELECTED) != 0 ? 'S' : '.');
    if ((mPrivateFlags&PFLAG_PREPRESSED) != 0) {
        out.append('p');
    } else {
        out.append((mPrivateFlags&PFLAG_PRESSED) != 0 ? 'P' : '.');
    }
    out.append((mPrivateFlags&PFLAG_HOVERED) != 0 ? 'H' : '.');
    out.append((mPrivateFlags&PFLAG_ACTIVATED) != 0 ? 'A' : '.');
    out.append((mPrivateFlags&PFLAG_INVALIDATED) != 0 ? 'I' : '.');
    out.append((mPrivateFlags&PFLAG_DIRTY_MASK) != 0 ? 'D' : '.');
    out.append(' ');
    out.append(mLeft);
    out.append(',');
    out.append(mTop);
    out.append('-');
    out.append(mRight);
    out.append(',');
    out.append(mBottom);
    final int id = getId();
    if (id != NO_ID) {
        out.append(" #");
        out.append(Integer.toHexString(id));
        final Resources r = mResources;
        if (id > 0 && Resources.resourceHasPackage(id) && r != null) {
            try {
                String pkgname;
                switch (id&0xff000000) {
                    case 0x7f000000:
                        pkgname="app";
                        break;
                    case 0x01000000:
                        pkgname="android";
                        break;
                    default:
                        pkgname = r.getResourcePackageName(id);
                        break;
                }
                String typename = r.getResourceTypeName(id);
                String entryname = r.getResourceEntryName(id);
                out.append(" ");
                out.append(pkgname);
                out.append(":");
                out.append(typename);
                out.append("/");
                out.append(entryname);
            } catch (Resources.NotFoundException e) {
            }
        }
    }
    out.append("}");
    return out.toString();
}

以上

发表评论

您的电子邮箱地址不会被公开。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据