04-17-2012 06:45 AM
hi All ,
I am showing my app logo and a button at the top of the screen. Every thing is just OK but only problm is with the button which has to b align to right at a specifc positiion from right side
The problm I am facing is that when I place the button on the required position its not on the same place on all handsets
Here is my code
public HorizontalFieldManager getField(){
HorizontalFieldManager hfmc = new HorizontalFieldManager(HorizontalFieldManager.USE_ ALL_WIDTH|
HorizontalFieldManager.USE_ALL_HEIGHT)
{
protected void paint(Graphics graphics) {
int xForLogoImg = (Display.getWidth()*4)/100;
graphics.drawBitmap(0, 0, imgTitleBar.getWidth(),imgTitleBar.getHeight()+5, imgTitleBar, 0, 0);
graphics.drawBitmap(xForLogoImg, 0, imgTitle.getWidth(), imgTitle.getHeight()+5, imgTitle, 0, 0);
super.paint(graphics);
}
};
int left = Display.getWidth() /2 + ((Display.getWidth()*6)/100) ;
btn.setMargin(0, 0, 0, left);
hfmc.add(btn);
return hfmc;
}
I return an HFM on which my logo is drawn and button is added . I have set the left margin of the button to the extend I want to b
Its OK on 9800 resolution 360X480 but on 9780 (resoltuion 480x360) its more toward the left and as resolution inc button move more to left
thnx in advnc to all of u
Regards
Solved! Go to Solution.
04-17-2012 06:35 PM
Should be e.g.:
int left = Display.getWidth() - 100;Rather than "go to the middle, then a bit more"
04-18-2012 01:06 AM
thnx for ur reply @pbrebs
if do as u said than button looks OK on 9800 (resolution 360x480) but on resolution 480x360 and 640x420 button move more to the right even its label is shorten to adjust it thr
I need a genralized way so that button adjust itself with respect to resolution
Regards
04-18-2012 04:54 AM
Have you looked at the Style Field.FIELD_RIGHT?
This works in places and doesn't in other places, it all depends on the Manager. One place here I am confident it does not work is in HorizontalFieldManagers. But I think it does work OK in VerticalFieldManagers where the VFM has USE_ALL_WIDTH. So try adding your button to a VFM instead of a HFM, with Field,FIELD_RIGHT.
Aside from that, you are up for creating a customer Manager. This Manager will call the layout on the Button, then ask it how big it is, and use the Manager's width to determine the position to set this Fields Position. All pretty standard Manager stuff though fairly daunting to a Manager newbie.
You will find more on this in the following:
and
http://supportforums.blackberry.com/t5/Java-Develo
04-19-2012 08:26 AM - edited 04-19-2012 08:29 AM
Thnx @peter it helped .
But I dont understand I am placing two images using this same percentage method and its working fine and images are palced on right place with respect to resolutions
Why it did not worked for the button ?
Regards
04-19-2012 08:57 AM
Rim Fields are not consistent in the way they behave.
For example LabelField will only ask for the width it needs, BasicEditField will ask for all the width. BitmapFields will ask for the width they need, Buttons do different things depending on the level of OS. All very confusing.