是否有 Android 工具可以查找正在运行的应用程序的布局名称? [英] Is there an Android tool to find the name of a layout for a running app?

查看:20
本文介绍了是否有 Android 工具可以查找正在运行的应用程序的布局名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

我最近受雇维护一个非常的大型程序(只有两个活动、大约一百个片段和几百个布局).此外,布局的大部分内容(图像和文本)以及布局出现的顺序都是通过公司的 Web API 动态确定的.

遗憾的是没有文档.没有地图,纳达.早在他们拥有 Android 程序员之前,该公司就聘请了第三方来制作这个应用程序.而且代码的质量充其量也很差(甚至变量名也很混乱和矛盾).

因此,我花费了大约 70% - 90% 的时间只是为了更改 Button 的背景而搜索布局和代码.

问题

是否有可以运行的工具(也许在 Android Studio 的调试器中?)可以以某种方式吐出当前显示的布局文件的名称?

我的上司经常说将背景纹理从黑色更改为浅灰色".我在想:更改是微不足道的,但是找到 xml 文件可能需要一个小时.

--更新--

产生这个问题的项目不再在我的控制之下,所以这个问题已经没有实际意义了.但这似乎是一个常见问题,所以我将这个问题悬而未决.也许将来会出现某种工具/解决方案.我希望这个帖子对处于这种情况的其他程序员有用.

解决方案

还有

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.

解决方案

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:

这篇关于是否有 Android 工具可以查找正在运行的应用程序的布局名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆