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


background

i have been hired maintain very large program (only 2 activities, hundred fragments, , several hundred layouts). furthermore, of content of layouts (images , text) order layouts appear dynamically determined via company's web api.

unfortunately there no documentation. no map, nada. company hired 3rd party make app long before had android programmers. , quality of code poor @ best (even variable names confusing , contradictory).

consequently, spend 70% - 90% of time searching layouts , code change background of button.

question

is there tool 1 can run (perhaps in android studio's debugger?) can somehow spit names of layout files displayed?

my superiors like, "change background texture black light gray." , i'm thinking: change trivial, finding xml file take hour.

hierarchy viewer tool

in android device monitor, there button can click on called "dump view hierarchy ui automator".

this open ui hierarchy viewer in device monitor, can use see resource ids of each of views.

while not give name of inflated xml file, useful. if lucky, can grep resource ids narrow down search xml files at.

and if hover on title of viewer window, show path actual xml file created. way find resource ids in 1 place.


some more info on hierarchy viewer in case helps:

the hierarchy viewer allows debug , optimize user interface. provides visual representation of layout's view hierarchy (the layout view) , magnified inspector of display (the pixel perfect view).


create custom layout inflater in code

here's blog post contains interesting - custom layout inflater intercepts view inflation:

it may possible use sample code intercept inflate calls, , receive resource id of xml file:

at point, need turn resource id useful name. quoting question (how resource name resource id), can use:

getresources().getresourceentryname(int resid); 

add logging , may give each xml file being inflated.

this quite nice way document entire project.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -