Skip to content

Feature Request: Add Position Coordinates to View Hierarchy Output #181

@thisames

Description

@thisames

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions