Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10451] Android: 'ellipsize' label property does not work on Android 4.x

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2017-07-19T18:50:05.000+0000
Affected Version/sRelease 2.1.1, Release 2.1.2
Fix Version/sn/a
ComponentsAndroid
LabelsSupportTeam, api, exalture
ReporterFederico Casali
AssigneeJoshua Quick
Created2012-08-15T11:57:37.000+0000
Updated2018-08-06T17:57:35.000+0000

Description

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

Attachments

FileDateSize
AndroidOS2.2.png2012-08-15T11:57:37.000+000014097
AndroidOS4.x.png2012-08-15T11:57:37.000+000029284

Comments

  1. sunil alachi 2012-12-15

    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
  2. Sunila 2013-02-21

    This is an Android SDK bug. Here is the link http://code.google.com/p/android/issues/detail?id=882
  3. kent hao 2013-02-23

    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
  4. Sunila 2013-02-23

    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.
  5. kent hao 2013-02-23

    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.
  6. Lee Morris 2017-03-29

    Closing ticket as "Not Our Bug".
  7. Joshua Quick 2017-06-20

    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.
  8. Joshua Quick 2017-07-11

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/9211
  9. Eric Merriman 2018-08-06

    Cleaning up older fixed tickets from 2016 and earlier. If this ticket should not have been closed, please reopen it.

JSON Source