Rotation on phone does not scale label and images back

38 views
Skip to first unread message

wicky...@gmail.com

unread,
Jan 30, 2014, 11:39:59 AM1/30/14
to codenameone...@googlegroups.com

Hi,

 I am running into an issue where when i Rotate to landscape, the labels and images scale correctly and fill the screen.
However when rotate back, the label and image does not scale back.

This happens in a list where i have a custom renderer.
I have tried both table layout with width percentage.....as well as border layout. Same story, The scale is done when rotating for the first time, either to landscape or vice versa.
But it does not scale back, and fit the screen.

Am i doing something wrong?

Here is the code.....


       
 Container c = new Container(new BorderLayout());
        c
.setUIID("ShopListRenderer");
        c
.setName("Shop");
       
//c.animate();
       
TableLayout _infoLayout = new TableLayout(3,1);
       
TableLayout.Constraint _c2 = _infoLayout.createConstraint(1,0);
        _c2
.setWidthPercentage(100);
       
Container _shopinfo = new Container(_infoLayout);
       
       
       
Label _name = new Label();
        _name
.setName("name");
        _name
.setUIID("ShopListName");
        _name
.setPreferredSize(new Dimension(180,26));
       
        _shopinfo
.addComponent(_name);
       
       
Label _location = new Label();
        _location
.setName("location");
        _location
.setUIID("ShopListLocation");
        _location
.setPreferredSize(new Dimension(190,18));
       
        _shopinfo
.addComponent(_c2,_location);
       
         
Label _hours = new Label();
        _hours
.setName("hours");
        _hours
.setUIID("CafeLabel");
        _hours
.setPreferredSize(new Dimension(190,28));
        _hours
.getStyle().setPadding(0, 0, 0, 0);
        _hours
.getStyle().setMargin(0, 0, 30, 0);        
        _hours
.getStyle().setFont(_resources.getFont("Description"));
       
       
        _shopinfo
.addComponent(_hours);
        _shopinfo
.getStyle().setBgTransparency(0);
        _shopinfo
.getStyle().setPadding(0, 0, 0, 0);
        _shopinfo
.getStyle().setMargin(10, 10, 0, 0);
        _shopinfo
.setPreferredSize(new Dimension(200,70));
       
       
        c
.addComponent(BorderLayout.CENTER,_shopinfo);
       
       
Label icon = new Label();
        icon
.setName("icon");
        icon
.setUIID("ShopListIcon");
        icon
.setPreferredSize(new Dimension(80,80));
        c
.addComponent(BorderLayout.EAST,icon);

       
       
return c;


Please advise.
Regards,
Wick

Shai Almog

unread,
Jan 30, 2014, 1:01:04 PM1/30/14
to codenameone...@googlegroups.com, wicky...@gmail.com
Hi,
you are invoking setPreferredSize which is usually the wrong thing to do since it blocks us from reflowing the layout properly.

wicky...@gmail.com

unread,
Jan 30, 2014, 1:16:29 PM1/30/14
to codenameone...@googlegroups.com, wicky...@gmail.com
Thank you for the quick reply.... :)
Reply all
Reply to author
Forward
0 new messages