Ruchi
Ruchi

Reputation: 5192

How to add image in label with TOP vertical alignment in codenameone?

I am facing an issue with TOP align of checkbox and any label image. I have set it's method setVerticalAlignment = TOP. but it's not working.

For Checkbox below code i have been used.

CheckBox c = new CheckBox();
c.setName(jobSequence);
   if(row%2==0){
   c.setUIID("oddCheck");
}
else{
   c.setUIID("evenCheck");
}
   c.setVerticalAlignment(TOP);

For status image icon below code i have been used.

Label statusLabel = new Label(res.getImage(imageName));
statusLabel.setUIID("login_title");
statusLabel.setVerticalAlignment(Label.TOP);

Any idea how to solve this ?

You can see issue in below image.

enter image description here

Upvotes: 1

Views: 68

Answers (1)

Diamond
Diamond

Reputation: 7483

Instead of:

CheckBox c = new CheckBox();
c.setName(jobSequence);
if(row % 2 == 0){
    c.setUIID("oddCheck");
} else {
    c.setUIID("evenCheck");
}
myContainer.addComponent(c);

Do this:

CheckBox c = new CheckBox();
c.setName(jobSequence);
if(row % 2 == 0){
    c.setUIID("oddCheck");
} else {
    c.setUIID("evenCheck");
}
myContainer.addComponent(FlowLayout.encloseIn(c));

Upvotes: 2

Related Questions