I need to prepare some objects based on the initial layout of widgets and views in my Activity. I'd like to do it in the initialization steps, ideally onCreate and onStart. Considering the possibility of changes that happen when we're not in the foreground, some of them might need to happen in onResume.
So I checked whether I could measure how my views had been laid out.
Log.d("MyApp", "w,h of X is " + findViewById(R.id.X).getWidth() +
"," + findViewById(R.id.X).getHeight());
I ran this in onCreate, onStart, and onResume. Each time I get 0,0 for width, height. If I wait for onTouchEvent I get the layout information, so the layout is done by then.
I'm surprised that the layout isn't set and final by the time I'm seeing onResume. I expected the widgets to be already laid out and ready to fiddle with by then.