0

I have started using LWUIT which sounds interesting , i have made a form and has simply added an image to its background , my problem is that the image is getting streched and looks bad :D is there any way to set an image not to get stretshd on a form or any other component ?

Lucifer
  • 29,392
  • 25
  • 90
  • 143
aida
  • 153
  • 1
  • 9

1 Answers1

2

This depends on the version of LWUIT you are using. In 1.4 you could define bgType in the Style to be BACKGROUND_IMAGE_ALIGNED and then define the bgAlign value to whatever you want (there are many types/alignments).

The latest SVN and upcoming 1.5 simplifies this by removing bgAlign and adding to bgType all the alignment/tiling possibilities e.g. BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_RIGHT or BACKGROUND_IMAGE_ALIGNED_TOP_LEFT etc...

You can edit all of these visually in the resource editor using the theme.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • thank you very much for this reply..im using 1.4 version of LWUIT and tried using bgType but it does not show my image...this is my code...kindly look into matter and let me know my mistake..regards – aida Jul 28 '11 at 15:38
  • private byte BACKGROUND_IMAGE_ALIGN_RIGHT ; public void startApp() { Display.init(this); Form main=new Form(); main.setLayout(new BorderLayout()); main.setLayout(new BoxLayout(BoxLayout.Y_AXIS)); try { Image image1 = Image.createImage("/progress0.png"); main.getStyle().setBgImage(image1); main.getStyle().setBackgroundType(BACKGROUND_IMAGE_ALIGN_RIGHT); } catch (IOException ex) { ex.printStackTrace(); } main.show(); – aida Jul 28 '11 at 15:41
  • i replaced this line : main.getStyle().setBackgroundType(BACKGROUND_IMAGE_ALIGN_RIGHT with main.getStyle().setBackgroundAlignment(BACKGROUND_ALIGNMENT); but still getting the same result for every type , the image is getting stretched filling the screen, how can i sole this problem?? – aida Jul 28 '11 at 15:49
  • 2
    Invoke setBackgroundType(BACKGROUND_ALIGNMENT) then for setBackgroundAlignment use BACKGROUND_IMAGE_ALIGN_RIGHT. This is all in the javadoc for these methods. – Shai Almog Jul 31 '11 at 05:54