Problem Description
When you create a label with a big text and the ellipsize set to true, the ellipsis won't be shown.
Test Case
1. Create a classic project
2. Paste this code as app.js:
var win = Ti.UI.createWindow({
backgroundColor : 'white',
exitOnClose : true,
fullscreen : false,
layout : 'vertical',
title : 'Label Demo'
});
var label2 = Ti.UI.createLabel({
color : 'blue',
text : 'A long label with a few line breaks and unicode (UTF8) symbols such as a white chess piece \u2655 and the euro symbol \u20ac looks like this! ',
textAlign : Ti.UI.TEXT_ALIGNMENT_LEFT,
//top : 30,
width : 200,
height : 100,
backgroundColor:'red',
lines: 1,
//layout:'horizontal',
//horizontalWrap: true,
//wordWrap: true,
ellipsize: true
});
win.add(label2);
win.open();
3. Run it in a device.
Expected: Truncated text in the label without ellipsis
Actual: You will see the truncated text in the label without ellipsis.
[~jnaher] Please use this as a workaround for now:-
When the property
wordWrap
is set tofalse
andellipsize
is set to true, it will behave as expected.There seems to be a related Android ticket for this: https://code.google.com/p/android/issues/detail?id=882 Thus, as mentioned in the solution earlier, setting
wordWrap: false
would solve the issue. Source code for that is here: https://github.com/appcelerator/titanium_mobile/blob/23c9e3fb93694950d33a8b4b79fbb2129ff9001b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUILabel.java#L246-L247 Resolving issue as there is already a workaround available and it's seems to be an Android issue.Hi guys, any news on this? I'm facing a problem with truncating, suggested idea partially works - it truncates the end, but also centers label in the middle(I have height and width set for label), so I see first sentence of a article. Have you any idea how to fix it? Thank you
PR (6.1.x): https://github.com/appcelerator/titanium_mobile/pull/9161
FR Passed for 6.1.1
PR (master): https://github.com/appcelerator/titanium_mobile/pull/9175
FR passed for master.
Verified the fix. Test info in the PR. Closing. Studio Ver: 4.9.0.201705302345 SDK Ver: 6.2.0.v20170623140932, 6.1.1.v20170623141152 OS Ver: 10.12.3 Xcode Ver: Xcode 8.3.3 Appc NPM: 4.2.9 Appc CLI: 6.2.2 Ti CLI Ver: 5.0.14 Alloy Ver: 1.9.11 Node Ver: 6.10.1 Java Ver: 1.8.0_101 Devices: ⇨ google Pixel --- Android 7.1.1 ⇨ google Nexus 5 --- Android 6.0.1