Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19433] Android 5 - Switch titleOn and titleOff are not displayed

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 4.1.0
Fix Version/sn/a
ComponentsAndroid
LabelsAndroid, Switch
ReporterJustin Toth
AssigneeUnknown
Created2015-04-28T21:29:19.000+0000
Updated2018-02-28T19:55:17.000+0000

Description

Using the sample code on [Titanium.UI.Switch](http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.UI.Switch), setting the titleOn and titleOff has no effect on Android 5, meaning that the text is not displayed. The switch control itself displays fine. !Screen Shot 2015-04-28 at 5.28.37 PM.png|thumbnail! Here is the code:
var win = Ti.UI.createWindow({
    backgroundColor: 'white'
});

var basicSwitch = Ti.UI.createSwitch({
    titleOn:'Notifications Enabled',
    titleOff:'Notifications Disabled',
    value:true,
    width: 200, height:120
});
win.add(basicSwitch);

basicSwitch.addEventListener('change',function(e){
    Ti.API.info('Switch value: ' + basicSwitch.value);
});

win.open();

Attachments

FileDateSize
Screen Shot 2015-04-28 at 5.28.37 PM.png2015-04-28T21:29:01.000+000055424
Screen Shot Ti SDK4.0.0 RC.png2015-04-29T04:40:42.000+000050299
SDK 3.5.1 GA.png2015-04-29T04:40:42.000+000041749
SDK 3.5.2 GA.png2015-04-29T04:40:42.000+000042389

Comments

  1. Andrew Tokmakoff 2015-09-25

    It seems that the default switch style under Android prior to release 4.0 was TOGGLEBUTTON and it is now SWITCH. http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Switch-property-style Adding an explicit style attribute fixed the issue for me. style: Ti.UI.Android.SWITCH_STYLE_TOGGLEBUTTON

JSON Source