For testing purposes, I need to get the coordinates of all visible views on the screen. However, when checking the output, it seems the UI Thread is not done drawing/positioning/applying settings to all the views yet. Some views are 0x0 pixels while they should be (and they are on both the emulator and a physical device) visible. Some bottom aligned buttons are positioned like stairs, et cetera.
Q: how can i wait for the UI Thread to complete drawing (or at least wait for like a second, that should be more than enough), so the coordinates of all visible views are accurate?
I suspects it's something with Threads, but I couldn't find any definitive answers. As of yet, I do not have any self-declared threads.
Edit: I use onBackPressed to make a bunch of views visible, then capture that in xml, make the previous views invisible and other views visible, capture that in xml, etc. I iterate trough a few different combinations of views and "xml-screenshot" each combination.