Saturday 12 July 2014

Font size global in all resolutions (android)

To accomplish this task you can check my test code below and see if it helps you.
 
var win = Ti.UI.createWindow({
    backgroundColor:'#fff',
});
 
var screenWidth = Ti.Platform.displayCaps.platformWidth;
var screenHeight = Ti.Platform.displayCaps.platformHeight;
 
function GetHeight(value) {
    var temp = (value * 100) / 480;
    return parseInt((screenHeight * temp) / 100);
}
 
function GetWidth(value) {
    var temp = (value * 100) / 320;
    return parseInt((screenWidth * temp) / 100);
}
 
var label = Ti.UI.createLabel({
        center:'0',
        color: '#019FCE',
        text: "Appcelerator Titanium Rockz !!!",
        font: {
            fontSize:GetHeight(15),
            fontFamily:'ABeeZee-Regular'
        },
        textAlign: 'center',
        wordWrap:true
});
 
win.add(label);
win.open();

No comments:

Post a Comment