I want to get the height/width of the Middle(Body) layout in onCreate() method.
My main.xml is :
Firstly, don't get view dimensions in onCreate()
since the view might not have been initialized yet. You can do it in the onStart()
method. All the views will have been inflated and laid out on the screen at that point:
@Override
protected void onStart() {
super.onStart();
ScrollView scrollView = (ScrollView) findViewById(R.id.svtest);
int width = scrollView.getWidth();
int height = scrollView.getHeight();
}