06-10-2011 10:16 AM
I cannot set the background of one of my Screens (which extends mainScreen). It's white no matter what I try.
Now I've read an article in the knowledgebase (mainScreen explained) which shows a workaround and mentions that setBackground never works for MainScreens.
But the reason I'm extending MainScreen is because I absolutely need the setTitle() and setStatus() methods. So I need the functionality of the MainScreen and I need a background. One that doesn't scroll and is always behind every field I add.
06-10-2011 10:31 AM
I tried the following and it works slightly:
WHITE, Color.WHITE, Color.BLUE, Color.BLUE));
Problem is it scrolls with my fields. I would like the color to stay where it is not stretch to take up the field container area.
06-10-2011 11:49 AM
1. Create your MainScreen with explicit NO_VERTICAL_SCROLL.
2. Add a VerticalFieldManager with VERTICAL_SCROLL | VERTICAL_SCROLLBAR to the screen.
3. Add the rest of the fields to this scrolling manager.
4. Set background on the main manager just as you've done.
This has a good chance to work properly. If it doesn't, override your scrolling manager's paintBackground and use drawShadedFilledPath. Don't forget to add getHorizontalScroll to all xPts and getVerticalScroll to all yPts in order for the background to stay docked. The first part is not that relevant for a manager without horizontal scroll, but it's a good discipline anyway. You can omit it as long as you understand what you are doing.
06-10-2011 12:15 PM
Thanks for the reply.
Makes sense, but this way I'll lose the setTitle() and setStatus() functionality. I need these for my header image and toolbar to work properly.
06-10-2011 02:28 PM
You absolutely retain your banner, status and title functionality - what made you think you would lose them?
06-10-2011 02:52 PM
Sorry I think I misunderstood.
I was just thinking that VerticalFieldManager doesn't have setTitle() and setStatus() methods, but I'm sure you were thinking I should just call these methods for the mainScreen.
06-10-2011 03:05 PM
Exactly. When you setBanner, setTitle and setStatus on the MainScreen, it subsequently limits the width and height passed into the sublayout of its main manager. If that main manager is not scrolling, it then passes the same values to your VerticalFieldManager's sublayout (scrolling managers let their children have (Integer.MAX_VALUE >> 1) total size along the scrolling axis).
So the conclusion is this: your title and status will be intact; your inner manager will have properly reduced visible height because of them.
06-10-2011 03:46 PM
What if I need it to scroll?? In my case I have lists.
Would I have to place a scrollable VerticalFieldManager inside the NonScrollable one??
06-10-2011 04:46 PM
That's exactly what I said when I outlined what you need to do.