I am adding a VerticalFieldManager to a screen. I'm painting a background image and to remove whitespace at the bottom of screen when user scrolls down im overriding sublayout in my verticalfieldmanager like so:
protected void sublayout( int maxWidth, int maxHeight ) {
super.sublayout( maxWidth, maxHeight );
setExtent(maxWidth,Constants.BACKGROUND_IMAGE.getHeight());
}
This doesn't work -- white space appears at the bottom of the screen when the us开发者_JAVA技巧er scrolls down. I thought overriding sublayout, using the same code, on the screen object would take precedence over the VerticalFieldManager, which is a child of the screen.
A couple things to check. If, on your MainScreen, you're calling super(VERTICAL_SCROLL | USE_ALL_WIDTH)
then your Screen's manager will be the one actually scrolling down, not the VFM you've customized. You may try overriding the paint() method of your VFM and do something as such:
protected void paint(Graphics graphics) {
graphics.drawBitmap(0, getVerticalScroll(), bg.getWidth(), bg.getHeight(), bg, 0, 0);
super.paint(graphics);
}
Which should make your background "move" with the scroll.
精彩评论