Question

Good evening,

I'm using Eclipse with the UI-Framework Codename One.

I would like to know how it would be possible to scale an image to fit the width of the screen? I would like to create a list with one image( or even an imageslider if this is possible), which has the full width of the phone, and under that some text.

Another question is, how can I set an Image via Hastable and Vector from code ? I tried everything but I can't find a solution.

Thank you a lot,

Greetings Patric

Was it helpful?

Solution

It depends on what you are trying to do.

Normally you would just set the image as the background image of the component and select the background behavior as SCALE_TO_FIT which can be done both via the theme designer and via the Style object of the component.

You can also use the ImageViewer class if you want to have a viewable/zoomable image.

You can also just scale the image to the size you want using either the scaled() method or ImageIO.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top