Is there an Android tool to find the name of a layout for a running app?

SMBiggs picture SMBiggs · Sep 30, 2015 · Viewed 9.3k times · Source

Background

I have been recently hired to maintain a very large program (only two Activities, about a hundred Fragments, and several hundred layouts). Furthermore, most of the content of the layouts (images and text) as well as the order that the layouts appear is dynamically determined via the company's Web API.

Unfortunately there is no documentation. No map, nada. The company hired a 3rd party to make this app long before they even had Android programmers. And the quality of the code is poor at best (even variable names are confusing and contradictory).

Consequently, I spend about 70% - 90% of my time simply searching for layouts and code just to change the background of Button.

Question

Is there a tool that one can run (perhaps in Android Studio's debugger?) that can somehow spit the names of the layout files that are currently displayed?

My superiors often say something like, "Change that background texture from black to light gray." And I'm thinking: the change is trivial, but finding the xml file could take an hour.

--Update--

The project that generated this question is no longer under my control, so this question has become moot. But it does seem to be a common issue, so I'm leaving this question open. Perhaps in the future some kind of tool/solution will be arise. I hope this thread is useful to other programmers in that situation.

Answer

Jarosław Wiśniewski picture Jarosław Wiśniewski · Jul 5, 2018

There is also the Developer Assistant app for Android which can inspect a view hierarchy at runtime and then display the most probable layout names visible on the screen. The heuristic is involved so it won't work 100% accurate, but still can be helpful and works completely offline (a disclosure: I made this app).

An example:

enter image description here