开发者

Override sublayout on a Screen or VerticalFieldManager

开发者 https://www.devze.com 2023-03-04 23:42 出处:网络
I am adding a VerticalFieldManager to a screen. I\'mpainting a background image and to remove whitespace at the bottom of screen when user scrolls down im overriding sublayout in my verticalfieldmanag

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号