开发者

Extend height of blackberry banner field

开发者 https://www.devze.com 2023-02-24 21:11 出处:网络
I am attempting to s开发者_如何学Cet the height of banner so that an entire image is painted at top of screen.

I am attempting to s开发者_如何学Cet the height of banner so that an entire image is painted at top of screen.

Here is my code to set the height of the banner -

protected void sublayout( int width, int height ) {
        Bitmap b = Constants.HEADER_LOGO;
        super.setExtent( b.getWidth(), b.getHeight() );
    } 

The banner height is adjusted correctly but I am unable to add fields to the banner using add method. No exceptions are thrown.

Is this the correct method of increasing the height of banner field ?

Thanks


This could depend on a couple of things. If your Bitmap isn't the width of your screen then you're probably not giving enough width for your Fields to layout. What I would probably do is change your super.setExtent() call to

super.setExtent(width, Math.min(b.getHeight(), height));

With this I am assuming that what you're trying to set as the banner is a HorizontalFieldManager. You'll notice the addition of a Math.min() call in there as well. The reason you want to do this is that your width and height are maximum allowed dimensions that the Manager can occupy, and if you try to call setExtent() with dimensions larger than it you will most likely get an error in your Console saying that there was insufficient room to layout.

So now that you have your Manager sizing itself properly, you can add your Fields to this HFM, then setBanner(hfm) and you should be golden!

0

精彩评论

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

关注公众号