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 ----->'
{panel:title=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 + ' ------->');
{panel}
Have you tested on device? I've tested it on devices and it shows the same behavior on both platforms. The auto has been deprecated so don't use it. I've one question, if your environment is windows then how can you test iOS on that? Please test it on a device.
Nikhil, he has not tested this on the device...this bug is submitted as a bug in the emulator. The only reason 'auto' was used in the testcode was to show that there is a difference between 'auto' and Ti.UI.SIZE. The code for 'auto' produces the correct result, so it was provided to shed some light on the potential problem. As many develpers do, everything is tested on the emulator first. If it doesn't work there, testing never gets to the device. As far as the Windows environment goes, this bug was submitted as an Android bug, which he runs on Windows. The code was copied to a Mac Mini to test on iOS, which functions correctly, so there was no need to specify the Mac environment info. If you need any more additional information, please let me know.
Lots of updates to this ticket last night, but still in "Resolved, Needs more info" status?
Tried with SDK 3.2.0 on Nexus S device and Emulator 2.2, shows the same value for both labels.
Closing ticket as I am unable to reproduce the issue using the following environment; Pixel (7.1) MacOS 10.11.6 (15G31) Studio 4.8.1.201612050850 Ti SDK 6.0.3 GA Appc NPM 4.2.8 Appc CLI 6.1.0 Ti CLI 5.0.11 Alloy 1.9.5 Arrow 1.10.1 Xcode 8.2 (8C38) Node v4.6.0 Java 1.7.0_80