• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How to center an item in a FORM i

 
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great

Happy to hear you've solved your problem.
 
If we don't do the shopping, we won't have anything for dinner. And I've invited this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic