Luca Brr
Luca Brr

Reputation: 87

Set programmatically a background image in a form in codename one

I'd like to set programmatically a background image for my form. I know I can do it with the designer, setting the UIID, but it's not what I need.In fact, I have many forms, each one with its own picture... There is a way to do it?

I hope I have been clear enough. Thank's in advance for any answer... Luca

Upvotes: 1

Views: 341

Answers (1)

James H
James H

Reputation: 1116

It's pretty easy to do. The things you would do in the designer can also be done with code, most of the actions are part of the element's style. You can do myForm.getAllStyles().setBgImage(your Image) or for a button or something you can also get pressed or selected styles to change the style for each state. Also, you can change the image behavior to scale it to fit or fill, etc. with setBackgroundType().

Upvotes: 1

Related Questions