Search code examples
androidiosfontssizetitanium

Titanium fontsize dependig OS


I'm trying to change the fontSize depending of the OS, but it doesn't work. Anyone can tell me what I'm doing bad?

my code:

font:{
    fontSize: os({
        ipad: '40',
        android:'30'
    })
}

example that I saw:

  font:{
    fontSize:40,
    fontFamily: os({
        iphone:'Spicy Rice',
        ipad: 'Spicy Rice',
        ipod: 'Spicy Rice',
        android:'SpicyRice-Regular'
    })
}

Solution

  • This is for fontFamily so if you want to set size then you need to check the os name first then you can set that. For that you need to use global variable which stores font Size.

    example...

    if(os == "android"){
        Alloy.Globals.fontSize = "30";
    }else if(os == "ipad"){
        Alloy.Globals.fontSize = "40";
    }
    

    do this in alloy.js then use Alloy.Globals.fontSize variable anywhere you want.