08-16-2012 09:51 AM
When you add it to a MainScreen, you are effectively adding to a VFM that the MainScreen manages.
This and more is covered in detail here:
If you have a normal VFM, that you add to the MainScreen, then that will work too, i.e. you can add to that. But remember both this VFM and the MainScreen must not scroll horizontally.
08-17-2012 05:06 AM
I'm not sure about a VerticalFieldManager, but a HorizontalFieldManager will just expand to the width required for the Fields you add. I suspect a VFM might as well, but I've never tried that.
Give it a try and tell us if you have problems.
08-17-2012 09:00 AM
As i am adding fields dynamically. Can i set width of manager according to fields that are getting added in the manager?
The built-in managers, such as VerticalFieldManager and HorizontalFieldManager, always relayout properly when the fields are added to them. So your HorizontalFieldManager will recalculate its width and virtual width with the addition of each field and will scroll accordingly.
The cost of relayout is not high until you get to some hundreds of fields...
08-18-2012 10:05 AM
Putting this bluntly, because you have coded something incorrectly. Most likely you have added something with USE_ALL_WIDTH. Alternatively you have created your own Manager and you do not set the extents correctly.
To find this problem, as I think I have suggested before, I recommend that you use the typical debugging technique of making things 'standard' and then slowly changing things until they break. Then you know what change broke the code.
In your case, start with just a standard MainScreen, with no style overrides, Add a LabelField as we have previously discussed, Make sure it fills the width of the screen and the text is centered. Then add a standard HFM with something simple in it, like a normal LabelField. Progress from there until the change you make to match what you want breaks it, i.e. Infinite scrolling sets in. Then you know what caused the problem. If you can't figure it out, you can ask about that specific issue.
But make sure you do the leg work. If you add a Field or Manager and suddenly it becomes infinitely scrolling, then look at the code you have in the Manager or Field that might be related to this, specifically the style attributes and the layout or sublayout processing. Change this and try again. You will get to the stage that you know what bit of code is actually causing the problem and/or not doing what you expect. So you can ask a focused question on a specific bit of code rather than a general "its not working" question.
Doing this will help you understand what each of the things you change actually does, as well as finding your problem.