I managed to get to the contents of the Activity using this call:
ViewGroup view = (ViewGroup)getWindow().getDecorView();
You should probably check that getDecorView returns a ViewGroup instance for all cases, but with the LinearLayout in Activity, the code above works fine. To get to LinearLayout, you could simply:
LinearLayout content = (LinearLayout)view.getChildAt(0);
And if you have a function like this:
void logContentView(View parent, String indent) { Log.i("test", indent + parent.getClass().getName()); if (parent instanceof ViewGroup) { ViewGroup group = (ViewGroup)parent; for (int i = 0; i < group.getChildCount(); i++) logContentView(group.getChildAt(i), indent + " "); } }
You can iterate over all views and write down the names of their classes with the following call inside your activity:
logContentView(getWindow().getDecorView(), "");
mikeplate Nov 21 2018-10-11T00: 00
source share