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'} }));
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);
-
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'}));
-
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.
-
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.
-
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