Ini
Ini

Reputation: 668

Qooxdoo Image centering

I have a problem with qooxdoo. I use a qx.ui.basic.Image with 244px width and height but the image-source is smaller. Now I want to center the image in the qx.ui.basic.Image. How can I do that?

var imageZoneTemp = new qx.ui.basic.Image("pathtoimagesource");
imageZoneTemp.set({
    width: 244,
    height: 244,
});

Upvotes: 0

Views: 208

Answers (2)

Tobi Oetiker
Tobi Oetiker

Reputation: 5460

Just use an atom:

var image = new qx.ui.basic.Atom(null, "next.png").set({
    center: true,
    show:   'icon',
    width:  244,
    height: 244
});

Upvotes: 1

scro34
scro34

Reputation: 66

I'd put the image into a qx.ui.container.Composite with an Atom layout that has its center property set to true:

var container = new qx.ui.container.Composite().set({
  layout: new qx.ui.layout.Atom().set({center: true}),
  width: 244, 
  height: 244
});

var image = new qx.ui.basic.Image("pathtoimagesource");
container.add(image);

Note that with this approach you don't assign width and height values to the image, but to the container.

Upvotes: 2

Related Questions