• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to center an item in a FORM i

 
Ould Nadif
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a problem to center an image (ImageItem) vertically with FORM.
I developp with MIDP1.0. I could center the image horizontally.
FORM form = new FORM("toto");
ImageItem item = new ImageItem("" , img1, ImageItem.LAYOUT_CENTER , "") ;
form.append(item);

Help me

OULD
Cheers
 
Yuri Magrisso
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you try to add LAYOUT_NEWLINE_BEFORE also:


If that doesn't do the trick may be you should consider using Canvas for that screen. You can extend a class from javax.microedition.lcdui.Canvas. In the paint(Graphics g) method (that you must override) just draw the Image using the Graphics parameter.
 
Ould Nadif
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
I tested your solution about a FORM to center a item vertically but it seems it doen't work. I prefer a solution with FORM. It'is right that a Canvas can solve my problem.I wondering if the Canvas solution may require more resources (memory ???) for example.

Cheers

OULD
 
Yuri Magrisso
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If there was a way to center verticaly an Image on a Form in MIDP 1.0 probably it would be shorter to code than the Canvas solution, which means that the jar size will be smaller. The jar size is always a problem in MIDP 1.0 phones. But then again I don't know of such way.
The LAYOUT_NEWLINE_BEFORE cannot center the Image vertically. At best it will move it down a little bit. With Canvas you can center it without problem.
 
Ould Nadif
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Yuri,

Thanks for your help.
Finaly, I implement Canvas instead of Form.
I could center my image.
Cheers

OULD NADIF
 
Yuri Magrisso
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great

Happy to hear you've solved your problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic