I am making an application that need to have layout items loaded dynamic. I have an XML where I have the design of the element that will be added multiple times on the stage. Also, I have a RelativeLayout that will hold the elements. To add an element to the RelativeLayout I use this:
...
View child = View.inflate(context, R.layout.buildinglayout, null);
parrent.addView(child, parrent.getChildCount()); //parrent is the relativeLayout
...
As you may guessed, buildinglayout.xml is the layout of the element. Everything is added to the stage correctly and apparently with no problems. The thing is that the element's to fit on the stage so I need to have a ScrollView that surrounds the RelativeLayout. The only problem is that the scrollview does not detect the actual width and height of the RelativeLayout. So...I did this:
...
View child = View.inflate(context, R.layout.buildinglayout, null);
parrent.addView(child, parrent.getChildCount()); //parrent is the relativeLayout
Log.v("BuildingView", "w:" + child.getWidth() + " h:" + child.getHeight());
Log.v("ParrentView", "w:" + parrent.getWidth() + " h:" + parrent.getHeight());
...
The output of those Log.v is:
03-29 06:56:43.803: VERBOSE/BuildingView(480): w:0 h:0
03-29 06:56:43.803: VERBOSE/ParrentView(480): w:0 h:752
Can anyone please tell me what to do so that the width and height of both the buildingview and the parrent to be corect?
P.S. I am using Android 3.0 on an emulator device