font attribute not working

You must Login before you can answer or comment on any questions.

Any ideas why the font size isn't being changed?

http://pastie.org/4378404

4 Answers

Accepted Answer

Hi Alan

There are two ways of creating tableviewrows, the first you are already used to, basically an array of data with each row having at least a title. This is basically fixed in presentation.

The second way and which Kosso is pointing out as a method is the way all other (more complicated) layouts are created.

You basically consider each tableviewrow as a view and add things to it, so you would add a label aligned to the left of the row for the title and another for the caption aligned to the right, you can change the way these are presented in the same way as any other labels you would add anywhere.

var rows = [];
 
var row = Ti.UI.createTableViewRow({
    height: Ti.UI.SIZE,
    width: Ti.UI.FILL
});
var lblTitle = Ti.UI.createLabel({
    color: '#000',
    font: {
        fontSize: 14,
        fontWeight: 'bold'
    },
    height: Ti.UI.SIZE,
    left: 10,
    text: 'Title',
    width: Ti.UI.SIZE
});
row.add(lblTitle);
var lblLabel = Ti.UI.createLabel({
    color: '#666',
    font: {
        fontSize: 14,
        fontWeight: 'normal'
    },
    height: Ti.UI.SIZE,
    right: 10,
    text: 'Title',
    textAlign: 'right',
    width: Ti.UI.SIZE
});
row.add(lblRow);
 
rows.push(row);
 
var tbl = Ti.UI.createTableView({
    data: rows,
    height: Ti.UI.FILL,
    width: Ti.UI.FILL
});
win.add(tbl);
This should give you a good starting point, obviously you will need to loop through adding rows to the rows array.

You need to use a label and add it to the row - also don't set the title.

Thanks for the answer, I'll take a look at it.

On an iPhone contact you get the key( mobile, home, work) in blue and the actually phone number in black with a larger font size. How do you do this in Titanium?

These are 2 labels, one blue, and one black each of them with a different fontSize.

Your Answer

Think you can help? Login to answer this question!