Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Posts: 29
Registered: ‎11-09-2008
My Device: Not Specified

Help with setting up a complex layout

[ Edited ]

I have recently finished up work on an android project and am porting the app over to the blackberry.  The client wants the same basic look and feel on both applications so I am trying to achieve that.

 

This is basically what i need to achieve.

 

A header logo, followed by a gradient label field that is the full screen width and a full screen background image.  I want these pieces to be unscrollable.  Under the header and label field I need custom buttons layed out vertically, this sections should be scrollable if the screen isn't large enough.

 

So basically the layout should be like this:

 

Header

-------------

Label Field

-------------

 

ImageButton

 

ImageButton

 

ImageButton

 

etc..

 

 

Here is what I have so far, but it seems like not all the fields are showing up.

 

 

public RimFinder()
{
//The background image.
backgroundBitmap = Bitmap.getBitmapResource("background.png");
headerLogo = Bitmap.getBitmapResource("logo.png");

FullScreen mainScreen = new FullScreen();

HorizontalFieldManager hfm = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH | HorizontalFieldManager.USE_ALL_HEIGHT){

//Override the paint method to draw the background image.
public void paintBackground(Graphics graphics)
{
//Draw the background image and then call paint.

graphics.drawBitmap(0, 0, Display.getHorizontalResolution(), Display.getVerticalResolution(), backgroundBitmap, 0, 0);
super.paintBackground(graphics);
}

public void paint(Graphics graphics){

graphics.drawBitmap(5, 5, headerLogo.getWidth(), headerLogo.getHeight(), headerLogo, 0, 0);
super.paint(graphics);
}

};


VerticalFieldManager navVfm = new VerticalFieldManager();


VerticalFieldManager mainVfm = new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL){

};


//A bitmap field with a transparent image.
//The background image will show up through the transparent BitMapField image.
//BitmapField bitmapField = new BitmapField(Bitmap.getBitmapResource("logo.png"));

//Add the manager to the screen.



mainScreen.add(hfm);
mainScreen.add(navVfm);
mainScreen.add(mainVfm);


NavField nav = new NavField(bundle.getString(RimLocatorResource.MAIN_MENU), DrawStyle.HCENTER, Display.getWidth());
navVfm.add(nav);

ImageButtonField imageButton = new ImageButtonField(bundle.getString(RimLocatorResource.SIGN_IN), Field.FOCUSABLE);
mainVfm.add(imageButton);


//Push the screen.
pushScreen(mainScreen);
}

 

 Any help would be greatly appreciated.

 

Message Edited by mistapony on 11-11-2008 01:14 PM
Message Edited by mistapony on 11-11-2008 01:15 PM
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Help with setting up a complex layout

Have you thought about starting with something easy? :-)

 

Next time it might be helpful to tell us what is not displaying/working.  I've looked at the code and guessed, but I might be wrong...

 

If you want a non scrolling bit at the top of the screen, then use MainScreen, and setTitle to set the non scrolling bit.  You can set a Manager in there, so you can have multiple Fields in the Title area.

 

You have a HorizontalFieldManager, which seems to have no Fields in it.  So it has no reason to get any Screen real-estate.  So I don't think you will see the background bitmap or the headerlogo.  I would add the headerlogo as a BitmapField to the hfm, and override its size and paint to get it laid out where you want.  But do that as phase 2, get it displayed on the screen first....

 

Your labelField seems to be in navVfm?  Is that correct?  I would add your hfm to navvfm first, then

mainscreen.setTitle(navvfm);

 

I think that will get the non scrollable bit you want.

 

The rest I think is working, so you don't need any help.

 

 

New Developer
Posts: 29
Registered: ‎11-09-2008
My Device: Not Specified

Re: Help with setting up a complex layout

Thanks for your help.  Okay I was able to get the header layout with the logo and field.  The only problem is it seems like there is a thick black line under the title field.  Originally the whole title background was black but i was able to change that to white.  Do you know what property the bottom border of the title field may be?
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Help with setting up a complex layout

I don't know for sure.

 

I believe that border is supplied by the Theme (as is the background color to the Title area) and there is not yet an official way to control the theme.

 

In a another post on this forum, someone has suggested that you can stop the theme by overriding the undocumented method applyTheme as follows.

 

protected void applyTheme() {

}

 

I've tested this and it does seem to get rid of the border.  However it removes a lot more as well, which is theme specific, such as the color of buttons.