×

Discussion Board

Results 1 to 3 of 3

Thread: Image on a Form

  1. #1
    Regular Contributor
    Join Date
    Jul 2003
    Posts
    63

    Image on a Form

    Is there any way to display a centered ( both horizontal and vertical ) image on a Form - the image being the only item on that form?
    Appending the image as ImageItem with ImageItem.LAYOUT_CENTER centers the image on horizontal, and if adding ImageItem.LAYOUT_VCENTER centers the image on vertical but in report to the item's row not to the screen and I need the image to be centered on the phone's screen ( not using a canvas or having the image the same size with the screen or getting Form height and then based on image height adding bogus items in order to shift the image on vertical).
    Last edited by ionutianasi; 2006-10-23 at 16:38.

  2. #2
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: Image on a Form

    hi,

    try that way:
    - add spacer to form (Item.LAYOUT_VEXPAND)
    - add image to form:
    Code:
    imageItem1 = new ImageItem("", get_image1(), ImageItem.LAYOUT_CENTER | Item.LAYOUT_VCENTER | Item.LAYOUT_2, null);                       
    imageItem1.setPreferredSize(122, 122);
    - add spacer to form (Item.LAYOUT_VEXPAND)
    then after setting form current displayable try:
    Code:
    get_spacer1().setPreferredSize(helloForm.getWidth(), ((helloForm.getHeight()-get_image1().getHeight())/2));
    get_spacer2().setPreferredSize(helloForm.getWidth(), ((helloForm.getHeight()-get_image1().getHeight())/2));
    hth,
    regards,
    Peter

  3. #3
    Regular Contributor
    Join Date
    Jul 2003
    Posts
    63

    Re: Image on a Form

    Thank you.
    As I was saying, "getting Form height and then based on image height adding bogus items in order to shift the image on vertical" seems to be the only option.
    So, adding just a Spacer as a first item with the preferred size
    (formHeight-imageHeight)/2
    and then adding the image, will do the trick (no need for the second spacer or the VEXPAND parameter or the prefered size for the image).
    Also tried adding a StringItem("","") with the same preferred size height as the spacer above and still works on sun WTK but not on Prototype 2.0 S60 MIDP Emulator.
    Anyway,not that it bothers me much but, in all the cases, the image isn’t quite centered (though I printed all the size parameters and they seem ok and also tried with 2 Spacers): the image is shifted a little bit down from the center.( 5 or so pixels; this means the up empty space height is around 10 pixels higher than the empty space from the bottom; tried to find a relation between it and any form/image sizes but no luck so far).

    All tests were done on emulators.

Similar Threads

  1. Opening a JPEG Image
    By ummarbhutta in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-02-15, 06:34
  2. how to cut some part of Image
    By mshouab in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2006-08-04, 09:05
  3. Add image to Dynamic Form ???
    By Shilpa13 in forum Symbian User Interface
    Replies: 0
    Last Post: 2006-05-04, 11:40
  4. HELP: Mutable Image to Immutable Image?
    By rj_cybersilver in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-03-26, 09:58
  5. image input element types in form -problem
    By seanos11 in forum Browsing and Mark-ups
    Replies: 0
    Last Post: 2004-11-01, 15:25

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×