Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3408] iOS: Expose Ti.UI.Label.textAlign "justify"

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2016-11-18T17:34:43.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.1.0
ComponentsAndroid
Labelsn/a
ReporterDoney
AssigneeHans Knöchel
Created2011-04-15T03:43:55.000+0000
Updated2016-11-18T17:37:52.000+0000

Description

Please put this into the next release. Allows for prettier text aligning in Labels.

Attachments

FileDateSize
native-test-case_alignment.zip2016-11-18T17:16:20.000+000025074
Screen Shot 2016-11-17 at 9.08.21 AM.png2016-11-17T17:46:59.000+000043101

Comments

  1. Doney 2011-04-15

    Also, letterSpacing would be GREATLY appreciated.

  2. Doney den Ouden 2011-12-26

    Still nothing? Please add these simple things to TiMobile (preferably iOS). It should be very easy to implement.
  3. Doney den Ouden 2011-12-26

    Using [CATextLayer](http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CATextLayer_class/Introduction/Introduction.html) might help.
  4. Doney den Ouden 2011-12-26

    Just came across [this](https://marketplace.appcelerator.com/apps/790#overview) paid module again, which is _insane_. Please make it free, so you can close this ticket and have some more satisfied users (read the reviews).
  5. Hans Knöchel 2014-05-22

    Still not available in the latest SDK on both iOS and Android. Can please someone check this?
  6. Ingo Muschenetz 2014-05-22

    To confirm, you are looking for justified text in labels, and on both iOS an Android?
  7. Marian Kucharcik 2014-12-05

    Yes, please add option to justify label to next release. Thanks
  8. Hans Knöchel 2016-10-29

    I just needed this property for the new KitchenSink, so let's expose it! Unfortunately, justified text alignment is not available natively on the Android platform, so this is iOS-only for now. PR: https://github.com/appcelerator/titanium_mobile/pull/8562 Unit-Test: https://github.com/appcelerator/titanium-mobile-mocha-suite/pull/8
  9. Abir Mukherjee 2016-11-17

    The bug appears to still be present. This is the environment I used: Node Version: 4.5.0 Mac OS: 10.12.1 Appc CLI: 6.0.0 Appc CLI NPM: 4.2.8 Titanium SDK version: 6.1.0.v20161116071014 Appcelerator Studio, build: 4.8.0.201611121409 Xcode 8.1 GM When using "textAlign: Ti.UI.TEXT_ALIGNMENT_JUSTIFY", the actual alignment is LEFT, so it appears that JUSTIFY property is being ignored. I tried this on both labels and textfields., I have a screenshot of what it looks like, and the sample code I used.
       var win = Ti.UI.createWindow({
         backgroundColor: 'white',
         layout: 'vertical',
         title: 'Label Demo'
       });
       
       var label1 = Ti.UI.createLabel({
         text: 'label1 text aligned to left',
         textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT,
         top: 90,
         width: 300, height: 40});
       
       var label2 = Ti.UI.createLabel({
         text: 'label2 text aligned to right',
         textAlign: Ti.UI.TEXT_ALIGNMENT_RIGHT,
         width: 300, height: 40});
       
       var label3 = Ti.UI.createLabel({
         text: 'label3 text aligned to center',
         textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
         width: 300, height: 40});
       
       var label4 = Ti.UI.createLabel({
         text: 'label4 text aligned to justify',
         textAlign: Ti.UI.TEXT_ALIGNMENT_JUSTIFY,
         width: 300, height: 40});
         
       var textfield1 = Titanium.UI.createTextField({
       	textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT,
           width:300, height:40,
           borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED}); 
       
       var textfield2 = Titanium.UI.createTextField({
       	textAlign: Ti.UI.TEXT_ALIGNMENT_RIGHT,
           width:300, height:40,
           borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED}); 
       
       var textfield3 = Titanium.UI.createTextField({
       	textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
           width:300, height:40,
           borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED}); 
       
       var textfield4 = Titanium.UI.createTextField({
       	textAlign: Ti.UI.TEXT_ALIGNMENT_JUSTIFY,
           width:300, height:40,
           borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED}); 
       
       win.add(label1);
       win.add(label2);
       win.add(label3);
       win.add(label4);
       win.add(textfield1);
       win.add(textfield2);
       win.add(textfield3);
       win.add(textfield4);
       win.open();
       
    !Screen Shot 2016-11-17 at 9.08.21 AM.png|thumbnail!
  10. Abir Mukherjee 2016-11-18

    I re-ran the testcase with additional text in the label, and found that the fix does work correctly. If there are not enough words to wrap around to multiple lines, the alignment behaves like LEFT. This behavior is consistent with Native as well. Therefore, the fix is validated.

JSON Source