前言
这个功能于2019年1~2月提交至AOSP中,id:8f004c85a0859b6fad16f26ac0fce7b2dc3db3b1
git log: Add helper methods for View attribute debugging Adding abilities to debug: - Attribute resolution stack (which resources are looked at when resolving an attribute) - Attribute value source (where did each attribute value get defined) - Get explicit style id (if a view had it set via style="...") This feature will be behind Settings.Global flag that Android Studio will set to the debugged application package ID. 翻译: 添加用于 View 属性调试的辅助方法 添加调试功能: * 属性解析堆栈(解析属性时查看哪些资源) * 属性值来源(每个属性值在哪里定义) * 获取明确的样式 ID(如果视图通过 style="..." 设置了它) 此功能将位于 Settings.Global 标志后面, Android Studio 将其设置为调试的应用程序包 ID。
使用场景
所有含自定义属性的自定义view都应使用此方法以帮助LayoutInspector/dump正常工作。
使用方法
以google在TextView中的使用为例:
也就是说把你自定义view的自定义属性使用xml声明好,即可在这里直接用对应的styleable去保存它的属性。