FastViewTree
is a Kotlin written android lib which provides the ability to fetch the view tree information during runtime.
FastViewTree
gives you another option during debugging some complex UI issue.
FastViewTree
comes with not only view tree info but also size and visibility info of the view.
The coordinates info of view is not yet included but is in the plan.
implementation ("com.hwilliamgo:fastviewtree:1.0.5")
function | explain |
---|---|
View?.getViewTreeString | 获取该View的view树信息,以字符串返回 |
Activity?.getViewTreeString | 获取该Activity的view树信息,以字符串返回 |
Activity.createButtonToPrint | 在Activity左上角创建一个按钮,点击后在回调中返回view树字符串 |
FastViewTree提供了回调的形式来为每个遍历到的View添加额外的你可以自定义的信息,例如:
val viewTreeInfo=getViewTreeString {v:View->
"x=${v.x}, y=${v.y}"
}
├──[ContentFrameLayout] android:id/content width=1080, height=2082 visibility=VISIBLE
└──[ConstraintLayout] no id width=1080, height=2082 visibility=VISIBLE
├──[AppCompatTextView] com.hwilliamgo.fastviewtree:id/tv width=225, height=57 visibility=VISIBLE
└──[LinearLayout] no id width=264, height=144 visibility=VISIBLE
├──[AppCompatButton] no id width=0, height=0 visibility=GONE
└──[AppCompatButton] no id width=264, height=144 visibility=VISIBLE