Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24479] Android: maxLines not working for Ti.UI.Label (regression)

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-03-15T22:42:30.000+0000
Affected Version/sRelease 6.0.2
Fix Version/sRelease 6.0.3
ComponentsAndroid
Labelsandroid, label, maxlines
ReporterCarlos Henrique Zinato
AssigneeFrankie Merzadyan
Created2017-03-13T12:06:51.000+0000
Updated2017-03-20T08:57:15.000+0000

Description

Label's property maxLines seems not to work since SDK 6 on Android. https://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Label-property-maxLines I've tested it on SDK 5.1.x and 5.5.x and it does work. On 6.0.2.GA, or 6.1.0.v20170312111734 it DOES NOT work. The funny thing is that it works correctly when the Label is inside a List Item template. here is a test code:
var win = Ti.UI.createWindow({
   theme: "Theme.AppCompat.Fullscreen",
   backgroundColor: '#fff'
});

var longString = "Welcome to the Appcelerator Platform! The Appcelerator Platform extends Appcelerator's Titanium platform to help you manage the entire lifecycle of the application with debugging, testing, deployment, crash monitoring and analytic data collection.";
var bigLabel = Ti.UI.createLabel({
   text:longString,
   color:'#4d4d4d',
   width:'90%',
   top:10,
   lines:1
});
win.add(bigLabel);
bigLabel.setMaxLines(1);

var myTemplate = {
   childTemplates: [
      {
         type: 'Ti.UI.Label',
         bindId: 'info',
         properties: {
            color:'#4d4d4d',
            left:0,
            maxLines:1
         }
      }
   ]
};

var listView = Ti.UI.createListView({
   top:300,
   width:'90%',
   templates: { 'template': myTemplate },
   defaultItemTemplate: 'template'
});
var sections = [];

var fruitSection = Ti.UI.createListSection();
var fruitDataSet = [
   {
      info: { text: longString }
   },
];
fruitSection.setItems(fruitDataSet);
sections.push(fruitSection);
listView.setSections(sections);
win.add(listView);

win.open();

Attachments

FileDateSize
maxLines.png2017-03-13T12:06:22.000+000075123

Comments

  1. Sharif AbuDarda 2017-03-13

    Hello, I can verify the issue in Android 6.0.1 with SDK 6.0.2.GA. maxLines not working for labels.
  2. Frankie Merzadyan 2017-03-13

    master: https://github.com/appcelerator/titanium_mobile/pull/8884. 6_0_X: https://github.com/appcelerator/titanium_mobile/pull/8885
  3. Carlos Henrique Zinato 2017-03-14

    Nice! Thanks Frankie! How should I proceed to use this fix in my code? Wait for a new release?
  4. Frankie Merzadyan 2017-03-14

    [~chmiiller] The fix is openly available so, if you wish, you can pull and build it to see if it fixes your problem but it's currently in the review and testing phase by our developers and testers so I recommend waiting to hear what the final verdict is at least and I think a 6.0.3 release is coming soon if you decide to wait for the release. I hope that was informational.
  5. Samir Mohammed 2017-03-15

    Fix is present in 6.0.3.v20170315154238. Test steps and information can be found at https://github.com/appcelerator/titanium_mobile/pull/8885
  6. Samir Mohammed 2017-03-17

    Fix also present it 6.1.0.v20170317060325. Test steps and information can be found at https://github.com/appcelerator/titanium_mobile/pull/8884
  7. Carlos Henrique Zinato 2017-03-20

    Yes it is @Frankie! Thank you so much. Gonna start using 6.0.3! Thanks

JSON Source