Examining the Android View Hierarchy at Runtime in Debug mode? - android

I'm in an activity and I can't find a particular view. ie findViewById(R.layout.someId) is returning null. So I would just like to see for the current activity what the actual view hierarchy is at runtime. How can I do this?

This perfectly well-worded question has been down-voted for reasons I cannot understand.
And the perfectly straightforward answer:
Yes, you can use the SDK HierarchyViewer tool to see your whole layout tree at runtime
is hidden behind a youtube link that keeps getting poked into answers that say something else or comments to the original question.
Here's a link to the current documentation for HV:
https://developer.android.com/tools/debugging/debugging-ui.html
Note that the YouTube video says this can only be used with the app running in the emulator but the documentation says it will also work on "devices running a developer version of the Android system." I certainly don't run my own Android phone, which I use for most of my dev testing, with a dev version of the OS, so I think the YouTube video is effectively correct if not technically correct.

I believe findViewById requires a parameter of R.id.someid and it cannot take layouts. For a layout you must use setContentView(R.layout.someId);
http://www.youtube.com/watch?v=PAgE7saQUUY

Related

Get the layout of other running apps in Android?

Is there a way I can get the hierchary view/layout of other running android apps? If that's not possible, could I possibly unpack the app's .apk file and get the information there? For example, there's a setting in developer options that allows you to get the bounds of every elememt on the screen like so
EDIT
I have come to realize that this is not allowed and goes completely against the Android SDK. I apologize for this error and will look more closely in the future.
I have found out that Google blocks any of this because it would require me to inject my own code into other apps, which is not allowed due to malicious behavior in past apps.

Chrome remote dev tools are disordered, like the screenshot below, even though I remove all the settings

When I used chrome to debug my Android App WebViews, the remote device tool show like the screenshots. It was disordered, and on the bottom of the window is always blank, like something on it. When I changed the window size, all cell size changed(but changed strange, not predictable), and I still cannot see all cells(Some were hide, some were block by the white, and some were block by other cells which were not what I want). Until now every time I open the remote dev tools, it just like this.
Chrome dev tools to debug common PC webs worked fine, anyone got any ideas?
I was having the same problem. Not a lot of help out there easily find-able. Figured i'd answer here in case some one else comes across this issue and this question:
According to this link the problem is a specific feature used in older webview versions, and the later versions of chrome dev tools not being compatible. Use an older version of chromium as a work around.
Here's how to identify where to download chromium. I used 62.0.3202 and it fixed this issue for me.
The answer from Ben Culmer is correct, but I have detailed description how to deal with it.
Yes, the problem is an old Android and the new Chrome. They are incompatible.
Here is step by step description how to find and set up old Chromium version to deal with it.

tools for creating and checking android layouts

I spend an unpleasant time looking for erros in my android layout, fields not showing up being the predominant one. As I see other people here also struggling a lot with android layouts I thought to throw this question in even so not completely according to the SO question guidelines.
What tools are out there to help with the creation of android layouts.
there is only one i know. its called http://www.droiddraw.org/
over the time i figured though that the best is still to create your own by code.
If you're using a newer SDK within Eclipse (eg android 4.0 or 4.1) it should help you with the layout (with much more functional drag and drop and alignment/spacing). However, you may still want to manually verify it to make sure it's exactly what you want, since you'll be changing other parameters too.

How works a deviceturn in Android

I would like to know how works a turn of Android device (from the point of view of the OS). I'm interested in this action, because my Android program can not save and RIGHT restore its state after any turn of device (I use it with OnSave... and OnRestore... methods), I've learned almost all tutorials, but in spite of that, I can't find the mistake. Thank you.
A very detailed information on this matter is located in Android documentation here.
You most likely need this section:
Retaining an Object During a Configuration Change

Where is the drawable for the handle of a SlidingDrawer defined?

I want to use a SlidingDrawer in an activity, and I would love to just use the built-in tray handle, rather than try to find or create my own. I found it online thanks to CommonsWare but I assume that they got it from the Android platform itself, so I figure it will benefit me in the long run to know where to find it, rather than just use their copy of it. I looked for it in my Android SDK installation, under platforms/android-8/android.jar/res/ but with no success.
Where can I find the above image, in the Android SDK itself, rather than just downloading it?
Look in the launcher app: ~\platform\packages\apps\Launcher\res\drawable\handle.xml
It uses all the drawables: tray_handle_normal, tray_handle_pressed, tray_handle_selected.
may be you can type android.R.drawable... in eclipse and let the intelli-sense display all the built in drawables.
but I think it's not there cause I searched for it and didn't find it too
thanks
Be carefull with using images that come with the system. Google itself states that they will not guarantee that these images will be included in the system in every release (the name may change). Also the design of your app will change if the user uses something like Blur or Sense that overrides a lot of the standard design items. If you use a copy of the drawable itself you now how your app will look and you can be sure that your app will keep working even if the manufacturer or Google changes the images that come with a device.

Categories

Resources