1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

View Hierarchy ( adb dumpsys )

Posted at

Androidアプリの不具合解析等で、View Hierarchyを見ることが良くあり、見方に困ったので纏めておきます。

View Hierarchyは名前の通り、Viewの階層を表します。

取得方法は下記

adb shell dumpsys activity top

取得される内容

    View Hierarchy:
      DecorView@8b35a8a[MainActivity]
        android.widget.LinearLayout{aafc8fb V.E...... ........ 0,0-1080,2028}
          android.view.ViewStub{9373d18 G.E...... ......I. 0,0-0,0 #102018a android:id/action_mode_bar_stub}
          android.widget.FrameLayout{9b28371 V.E...... ........ 0,66-1080,2028}
            androidx.appcompat.widget.ActionBarOverlayLayout{f749556 V.E...... ........ 0,0-1080,1962 #7f080064 app:id/decor_content_parent}
              androidx.appcompat.widget.ContentFrameLayout{a7f9d7 V.E...... ........ 0,154-1080,1962 #1020002 android:id/content}
                androidx.constraintlayout.widget.ConstraintLayout{8ef12c4 V.E...... ........ 0,0-1080,1808}
                  android.widget.ListView{d1ae5ad VFED.VC.. .F...... 0,0-1080,1808 #7f0800c4 app:id/sampleList}
                    androidx.constraintlayout.widget.ConstraintLayout{73cb0e2 V.E...... ..S..... 0,0-1080,126}
                      androidx.appcompat.widget.AppCompatTextView{3885c73 V.ED..... ..S..... 22,22-1058,104 #7f080080 app:id/function}
                    androidx.constraintlayout.widget.ConstraintLayout{12c9730 V.E...... ........ 0,129-1080,255}
                      androidx.appcompat.widget.AppCompatTextView{52d2fa9 V.ED..... ........ 22,22-1058,104 #7f080080 app:id/function}
                    androidx.constraintlayout.widget.ConstraintLayout{e78f92e V.E...... ........ 0,258-1080,384}
                      androidx.appcompat.widget.AppCompatTextView{d024ccf V.ED..... ........ 22,22-1058,104 #7f080080 app:id/function}
                    androidx.constraintlayout.widget.ConstraintLayout{47bf65c V.E...... ........ 0,387-1080,513}
                      androidx.appcompat.widget.AppCompatTextView{5001d65 V.ED..... ........ 22,22-1058,104 #7f080080 app:id/function}
              androidx.appcompat.widget.ActionBarContainer{b1f7a3a V.ED..... ........ 0,0-1080,154 #7f08002a app:id/action_bar_container}
                androidx.appcompat.widget.Toolbar{680e6eb V.E...... ........ 0,0-1080,154 #7f080028 app:id/action_bar}
                  androidx.appcompat.widget.AppCompatTextView{1c48 V.ED..... ........ 44,40-651,114}
                  androidx.appcompat.widget.ActionMenuView{5a2ae1 V.E...... ........ 1080,0-1080,154}
                androidx.appcompat.widget.ActionBarContextView{a7b0006 G.E...... ......I. 0,0-0,0 #7f080030 app:id/action_context_bar}
        android.view.View{b0506c7 V.ED..... ........ 0,2028-1080,2160 #1020030 android:id/navigationBarBackground}
        android.view.View{e1eb4f4 V.ED..... ........ 0,0-1080,66 #102002f android:id/statusBarBackground}

上記のView Hierarchyは、下記の画面を表示時に取得したものです。

View HierarchyからもListViewが表示されていることがわかります。

android.widget.ListView{d1ae5ad VFED.VC.. .F...... 0,0-1080,1808 #7f0800c4 app:id/sampleList}

さらに表示されているViewの状態もわかります。

android.widget.ListView    // クラス名
{
d1ae5ad                    // HashCode
 
V                          // Visibility (V, I, G)
F                          // FOCUSABLE (F=true, .=false)
E                          // ENABLED (E=true, .=false)
D                          // draw (.=not draw, D=draw)
.                          // SCROLLBARS_HORIZONTAL (H=true, .=false)
V                          // SCROLLBARS_VERTICAL (V=true, .=false)
C                          // CLICKABLE (C=true, .=false)
.                          // LONG_CLICKABLE (L=true, .=false)
.                          // CONTEXT_CLICKABLE (X=true, .=false)
 
.                          // PFLAG_IS_ROOT_NAMESPACE (R=true, .=false)
F                          // PFLAG_FOCUSED (F=true, .=false)
.                          // PFLAG_SELECTED (S=true, .=false)
.                          // PFLAG_PREPRESSED (p) / PFLAG_PRESSED (P=true, .=false)
.                          // PFLAG_HOVERED (H=true, .=false)
.                          // PFLAG_ACTIVATED (A=true, .=false)
.                          // PFLAG_INVALIDATED (I=true, .=false)
.                          // PFLAG_DIRTY_MASK (D=true, .=false)
 
0, 0                       // mLeft, mTop
-
1080, 1808                 // mRight, mBottom
 
#7f0800c4                  // mID
 
app:id/sampleList          // PackageName
}

参考

dumpsys : https://developer.android.com/studio/command-line/dumpsys?hl=ja
View : https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/view/View.java;l=6440?q=view.java&ss=android%2Fplatform%2Fsuperproject&hl=ja

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?