In Android when I am adding a view object like ImageView to FrameLayout view and then immediately trying to call layout() method to repositioned the added view object it is not working. But when I call the layout method alone after some new event e.g. touch event then layout() seems to work. This also happens when bringToFront() and layout() is used together, layout() does not seems to work together with other method. Is there any reason why is this like this? Also instead of adding view object in the middle of the screen can it be ADDED at some specific location in FrameLayout?
+2
A:
You should NEVER call layout() directly. This is used by the framework only. You must modify the View's layout params (getLayoutParams()) and call requestLayout().
Romain Guy
2010-09-09 01:00:09