Problem description
The 'ellipsize' property for labels does not work on Android 4.x
The ellipsis (...) is not shown at all
Sample code to reproduce
var win1 = Titanium.UI.createWindow({
backgroundColor:'red',
exitOnClose:true,
title:'win1: Main Window'
});
var label1 = Ti.UI.createLabel({
backgroundColor:'black',
color:'white',
ellipsize:true,
text:'This is some text to demonstrate the use of the ellipsize property of a label(click me!) This is some text to demonstrate the use of the ellipsize property of a label(click me!)',
height:66,
width:200,
font:{fontSize:16}
});
win1.add(label1);
win1.open();
See attached screenshots - one is relative to Android 2.2 and other one to Android 4.x
This looks like an Android SDK issue. Either setSingleLine or setMaxLines needs to be set on the Android textView. see http://code.google.com/p/android/issues/detail?id=882
This is an Android SDK bug. Here is the link http://code.google.com/p/android/issues/detail?id=882
are you sure it's the bug of android sdk 4.x? because then i look at the link, two things are weird: 1. the problem is issued in 2008, 5 years passed ....... 2. in the link, there's some comment(#47) say it's working perfect in 4.x
This works in some special cases like if the line is set to singleLine or setMaxLines is set. In our case, we can't make the line as singleLine. To set the maxLines, the number of lines needs to be calculated dynamically which really depends on the font, spacing, text etc.
thanks for your reply. you mentioned dynamically calculation, could you please give me some hint about how to do that? maybe it's not the proper place for Q&A, but it will be great if you give me some link.
Closing ticket as "Not Our Bug".
Re-opening because this is a valid request. Especially since iOS and Windows Phone supports this. Note that the prior comments are correct. The Android OS does not support showing ellipsis when setting the Label view height. Android only supports ellipsis when setting the "lines" and "maxLines" properties. So, we would have to calculate the visible lines ourselves in Java.
PR (master): https://github.com/appcelerator/titanium_mobile/pull/9211
Cleaning up older fixed tickets from 2016 and earlier. If this ticket should not have been closed, please reopen it.