Skip to content
tezvyn:

How do you debug a running app's view hierarchy?

Source: developer.android.comMediumHow cards are made

How do you debug a running app's view hierarchy?

Tests practical debugging skills. A good answer names the Layout Inspector, describes the component tree and attributes panes, and explains how the 3D view finds hidden elements. A red flag is only naming the tool without explaining its use.

What's really being asked

This question tests your practical, hands-on experience with Android Studio's core debugging tools. The interviewer wants to confirm that you can move beyond print statements and efficiently diagnose common UI problems. It's a test of workflow efficiency and familiarity with the modern toolchain, not just theoretical knowledge.

The full answer

A strong answer identifies the tool and explains how to use it. First, name the Layout Inspector. Second, describe its three main parts: the Component Tree for the full View or Composable hierarchy, the Layout Display for an interactive 2D/3D rendering, and the Attributes pane for detailed properties. Third, explain the information it provides, such as a view's final on-screen dimensions, padding, constraints, or a Composable's parameters. Finally, give a specific use case, like using the 3D view to find an overlapping view that's stealing clicks.

The mistakes people make

A weak answer is just saying "Layout Inspector" and stopping. This shows a lack of depth. Another red flag is mentioning the older, deprecated "Hierarchy Viewer" tool without clarifying that Layout Inspector is the modern replacement. Candidates also fail when they can't explain what specific information the tool provides, like resolved colors or final coordinates. Confusing it with the Layout Validator (for different screen sizes) or the Profiler (for performance) is also a mistake.

What usually comes next

Expect follow-ups like, "How would you use it to debug why a Composable is recomposing too often?" (Answer: Check the recomposition counts and skips highlighted by the Inspector). Or, "A button isn't clickable. How would the Layout Inspector help?" (Answer: Use the 3D view to see if another transparent view is layered on top, intercepting touch events).

A concrete example

I had a bug where an icon wasn't appearing. Using the Layout Inspector, I selected the ImageView in the Component Tree. The Attributes pane showed its final rendered size was 0x0 pixels. This immediately told me the problem was a layout issue, likely with its constraints, rather than an issue with loading the drawable resource. It focused my debugging on the correct file and saved significant time.

Interview question

Which Android Studio tool would you use to diagnose why a button isn't clickable due to a suspected overlapping view?

  • a.Android Profiler, to check for UI thread blockages causing unresponsiveness.
  • b.Layout Inspector, using its 3D view to identify overlapping elements.Correct
  • c.Layout Validator, to ensure the button's layout is correct across device configurations.
  • d.Logcat, by adding print statements to track touch event propagation.
Why?

The Layout Inspector's 3D view is specifically designed to visualize the z-order of views, making it ideal for identifying overlapping elements that might be intercepting touch events. While the Android Profiler can help with general unresponsiveness, it does not visualize UI overlap.

Just read this? Test yourself on what you have been reading.

Read the original → developer.android.com

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on android — each one lists the topics its interview covers.

See open roles