Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3202] Android Bug: height or width set to 'auto' not available to reference

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-05-17T14:06:44.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.7.0
ComponentsAndroid
Labelsandroid, auto, defect, height, klist, label, reported-1.6.0, rplist, width
ReporterAlan Leard
AssigneeDon Thorp
Created2011-04-15T03:39:19.000+0000
Updated2011-05-17T14:06:44.000+0000

Description

If a label width or height is set to 'auto' on android you can not reference label.width or label.size.with. Both work on iOS.

Comments

  1. Don Thorp 2011-04-15

    Fixed title, fixed tags, Please provide code that demonstrates the example. If this came from Helpdesk, you need to include that link and add the rplist tag.

    Also this behavior is going to be addressed in 1.7.0 as the API is inconsistent on both platforms.

  2. Alan Leard 2011-04-15

    Here is some testing code:

       var win = Ti.UI.createWindow();
       
       var label = Titanium.UI.createLabel({
           text:'Text',
           color:'#000000',
           font:{ fontFamily:'Helvetica Neue', fontSize:18, fontWeight:'bold'},
           textAlign:'left',
           left:15,
           top:2,
           height:26,
           width:'auto'
       });
       
       win.add(label);
       
       alert('label.width: '+label.width);
       
       alert('label.height: '+label.height);
       
       alert('label.size.width: '+label.size.width);
       
       alert('label.size.height: '+label.size.height);
       
       win.open();
       

    Reference HD Ticket: http://developer.appcelerator.com/helpdesk/view/74851">http://developer.appcelerator.com/helpdesk/view/74851

  3. Dawson Toth 2011-04-15

    Simpler Sample Code

       var label = Ti.UI.createLabel();
       label.height = 'auto';
       alert(label.height);
       

    Tested On

    Titanium SDK version: 1.6.0 (02/23/11 12:34 9882e81)
    WORKS on iPhone Simulator 4.2
    BROKEN on Android Device EPIC 4G 2.1

    2nd Helpdesk Ticket

    http://developer.appcelerator.com/helpdesk/view/75481">http://developer.appcelerator.com/helpdesk/view/75481

  4. Don Thorp 2011-04-15

    In 1.7.0 that should return the layout setting on both iOS and Android. Having configuration properties doubling as dynamic values causes all sorts of problems like this. The correct response from this is 'auto'

  5. Dawson Toth 2011-04-15

    Workaround

    While we fix this, the following workaround will allow you to achieve the same results with only a little bit more work.

       var label = Ti.UI.createLabel();
       label.rawHeight = label.height = 'auto';
       alert(label.rawHeight);
       
  6. Paul Dowsett 2011-04-25

    For the above usecase to work, the label's size property must be queried after the window has been opened, using the window open eventListener:
       win.addEventListener("open", function(){
       	Ti.API.info("label.size.width = " + label.size.width);
       	Ti.API.info("label.size.height = " + label.size.height);
       });
       
    Doesn't iOS require this?
  7. Eric Merriman 2011-05-17

    On iOS, the test app reports: "2" On Android, the test app reports: "auto" I slightly modified the code: var label = Ti.UI.createLabel(); label.height = 'auto'; alert('Label height is: '+label.height);
  8. Eric Merriman 2011-05-17

    Closing as this is correctly reporting "auto". Created new iOS bug to attempt parity. The bug is TIMOB-4123.

JSON Source