[TIMOB-19433] Android 5 - Switch titleOn and titleOff are not displayed
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Release 4.1.0 |
Fix Version/s | n/a |
Components | Android |
Labels | Android, Switch |
Reporter | Justin Toth |
Assignee | Unknown |
Created | 2015-04-28T21:29:19.000+0000 |
Updated | 2018-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
File | Date | Size |
---|---|---|
Screen Shot 2015-04-28 at 5.28.37 PM.png | 2015-04-28T21:29:01.000+0000 | 55424 |
Screen Shot Ti SDK4.0.0 RC.png | 2015-04-29T04:40:42.000+0000 | 50299 |
SDK 3.5.1 GA.png | 2015-04-29T04:40:42.000+0000 | 41749 |
SDK 3.5.2 GA.png | 2015-04-29T04:40:42.000+0000 | 42389 |
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