Summary
what do you guys think in add an optional parameter to include position coordinates (x, y) in the view hierarchy output, making it easier to understand the spatial layout of views on screen.
Motivation
Currently, Radiography displays the dimensions (width × height) of each view but doesn't show their position on screen. This makes it difficult to:
- Debug layout positioning issues
- Understand overlapping views
- Identify views at specific screen coordinates
- Correlate the hierarchy with visual bugs in screenshots
Current Output Example
DecorView { 1080×2400px }
╰─LinearLayout { 1080×2400px }
├─ViewStub { id:action_mode_bar_stub, GONE, 0×0px }
╰─FrameLayout { id:content, 1080×2400px }
╰─ComposeView { 1080×2400px }
╰─Button { 954×147px, role:Button }
Proposed Output Example (with positions)
DecorView { 1080×2400px@(0,0) }
╰─LinearLayout { 1080×2400px@(0,0) }
├─ViewStub { id:action_mode_bar_stub, GONE, 0×0px@(0,0) }
╰─FrameLayout { id:content, 1080×2400px@(0,0) }
╰─ComposeView { 1080×2400px@(0,0) }
╰─Button { 954×147px@(63,1226), role:Button }
Proposed Solution
Add an optional includePosition parameter to the Radiography.scan() method that defaults to false to maintain backward compatibility.
API Changes
fun scan(
scanScope: ScanScope = AllWindowsScope,
viewStateRenderers: List<ViewStateRenderer> = DefaultsNoPii,
viewFilter: ViewFilter = ViewFilters.NoFilter,
includePosition: Boolean = false // New parameter
): String
Usage Example
// Default behavior (backward compatible)
val hierarchy = Radiography.scan()
// With position coordinates
val hierarchyWithPositions = Radiography.scan(includePosition = true)
I'm happy to submit a PR with the proposed changes if the maintainers are interested in this functionality.
Summary
what do you guys think in add an optional parameter to include position coordinates (x, y) in the view hierarchy output, making it easier to understand the spatial layout of views on screen.
Motivation
Currently, Radiography displays the dimensions (width × height) of each view but doesn't show their position on screen. This makes it difficult to:
Current Output Example
Proposed Output Example (with positions)
Proposed Solution
Add an optional
includePositionparameter to theRadiography.scan()method that defaults tofalseto maintain backward compatibility.API Changes
Usage Example
I'm happy to submit a PR with the proposed changes if the maintainers are interested in this functionality.