Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-12599

Android: label.toImage().width does not return correct width when Ti.UI.SIZE is assigned

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Cannot Reproduce
    • Affects Version/s: Release 3.0.0
    • Fix Version/s: None
    • Component/s: Android
    • Environment:

      Android 2.2 (Emulator)
      Titanium Mobile SDK 3.0.0.GA
      Windows 7

      Description

      Problem

      Titanium documentation says that width property value of 'auto' has been deprecated and to use Ti.UI.SIZE. However, setting label.width to Ti.UI.SIZE causes label.toImage().width to always return value of 100. Setting the label.width to 'auto' always returns the correct width. This problem occurs on Android only and is not a problem on iOS so this is a parity issue.

      Testcase

      Run enclosed app.js file on Android emulator. This app will display two labels. Label one will be created with width:'auto' and label two will be created with width:Ti.UI.SIZE. The function .toImage() will be called to get the width of each label. The results will be displayed in the console.

      Expected Result
      <----- The width of label one using property width:'auto' is 145 ----->
      <----- The width of label two using property width:Ti.UI.Size is 145 ----->'

      Actual Result
      <----- The width of label one using property width:'auto' is 145 ----->
      <----- The width of label two using property width:Ti.UI.Size is 100 ----->'

      app.js

       
      var win1 = Titanium.UI.createWindow({  
          backgroundColor:'blue'
      });
       
      var label1 = Titanium.UI.createLabel({
      	color:'yellow',
      	top:100,
      	text:'This is label one',
      	width:'auto'
      });
       
      var label2 = Titanium.UI.createLabel({
      	color:'red',
      	top:200,
      	text:'This is label two',
      	width:Ti.UI.SIZE
      });
       
      win1.add(label1);
      win1.add(label2);
       
      win1.open();
       
      Ti.API.info('<------- The width of label one using property width:\'auto\' is ' + label1.toImage().width + ' ------->');
      Ti.API.info('<------- The width of label two using property width:Ti.UI.Size is ' + label2.toImage().width + ' ------->');
      
      

        Attachments

          Activity

            People

            • Assignee:
              sunila Sunila
              Reporter:
              joejohnson Joe Johnson
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-15554
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Integration