Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Font Size in TableViewRow not working

This might be a dumb question, but the font size won't work in table view row. No matter how I try to code it - it won't work!! The color DOES work however. Can anyone help out??

Here is the code:

section.add(Ti.UI.createTableViewRow({title:'phone number', font:{fontSize:10, fontWeight:'bold'} }));

— asked November 19th 2010 by Erick Arbe
  • font
  • row
  • size
  • table
  • tableviewrow
0 Comments

5 Answers

  • TableViewRow is a view, which means you can use its add() method to add child views and widgets. Take a look at the KitchenSink table view layout 2 example to see how to build up a custom row. (see KitchenSink/Resources/examples/table_view_layout2.js). Here's a simple example:

    var row = Ti.UI.createTableViewRow();
    var label = Ti.UI.createLabel({ font:{ fontSize:10 }, 
                                    text:'custom text' });
    row.add(label);
    
    — answered April 28th 2011 by John Olmstead
    permalink
    1 Comment
    • Oops, should have looked at answer below closer, at lease this is more concise.

      — commented April 28th 2011 by John Olmstead
  • OK, got it - here is a sample code for anyone else out there wondering how to do this:

    var rowLabel = Ti.UI.createLabel({
        font:{fontSize:13,fontWeight:'bold'},
        width:'auto',
        color:'#968331',
        textAlign:'right',
        top:13,
        right:240,
        height:16,
        text:'phone'
    });
    
    var phoneNumber = Ti.UI.createLabel({
        font:{fontSize:18,fontWeight:'bold'},
        width:'auto',
        textAlign:'left',
        top:13,
        left:70,
        height:16,
        text:'650.469.3255'
    });
    
    var phone = Ti.UI.createTableViewRow();
    
    phone.add(rowLabel, phoneNumber);
    
    // add rows to section
    data[0] = section;
    
    section.add(phone);
    
    section.add(Ti.UI.createTableViewRow({title:'Something'}));
    section.add(Ti.UI.createTableViewRow({title:'Something Else'}));
    section.add(Ti.UI.createTableViewRow({title:'Another Something'}));
    
    — answered November 19th 2010 by Erick Arbe
    permalink
    1 Comment
    • This is a work around. If anyone finds an answer how to change font using the table's properties, do share!

      — commented April 19th 2011 by Joe iEntry
  • This is all great but why have font-size property in the documentation if it does not work! Wish TI folks would sort out the API docs they are appalling.

    — answered October 28th 2011 by Cameron Cooke
    permalink
    0 Comments
  • I have not been successful in doing that either. I am not sure if it is a limitation of titanium or the underlying OS, but how I work around it is by not using the title property then instead adding a label to the row. When you add objects directly to the row (or to a view added to the row), you gain complete control over the look no matter how complex you make it.

    — answered November 19th 2010 by Doug Handy
    permalink
    1 Comment
    • Doug, would you mind pasting in a sample of how you do this? I have tried several methods to get this to work and I keep ending up with a blank row! Thank you very much for the answer!

      — commented November 19th 2010 by Erick Arbe
  • One additional question. When you add the label to the row, you are able to control the look which is great, but if you "check" the row I notice that the words in the row respond with an undesirable jump as if the label was being re-rendered to the row after the user checks it or something. How can I solve this issue? Thanks

    — answered November 16th 2011 by San Pathak
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.