Hello Community!
I am trying to apply a custom image sheet to widget.newSwitch({ style = “onOff” }).
As a starting point i took the @4x image sheet of the Android Holo Light design that is provided via Github.
I just wanted it to look quite alike but with other colors. So i changed some of the colors with paint.net (ya! sick skills) and put the file into the base folder of the project. I also copied the sheet.luafile that is provided by Coronalabs into the base directory.
I also set:
widget.setTheme( "widget\_theme\_android\_holo\_light" ) -- set basic theme
I placed some of the customized switches in the scene (checkboxes & radioButtons), which you can see on the left and the ‘onOff’ switches on the right.
For both states I placed one switch (one “off”, one “on”). The two below are the standard ones, provided by Corona SDK and as you can see, there are no problems with it. My customized switches however do not show as I expected.
I was for errors for a while and did not came up with a solution… After a while I thought that this could also be an error or bug in the SDK and then found the daily build 2016.2980 in which some errors with newSwitch where fixed but the problem is still there for me.
The lines of code that create the switch:
local sheetInfo = require("widget\_theme\_android\_holo\_light\_sheet@4x") local imageSheet = graphics.newImageSheet( "dn\_blue\_widget\_theme\_android\_holo\_light@4x.png", sheetInfo:getSheet() ) local testSwitch = widget.newSwitch( { x = 200, y = 200, style = "onOff", onPress = onSwitchPress, sheet = imageSheet, frameOff = sheetInfo:getFrameIndex("switch\_checkboxSelected"), frameOn = sheetInfo:getFrameIndex("switch\_checkboxDefault"), onOffBackgroundFrame = sheetInfo:getFrameIndex("switch\_background"), onOffMask = "widget\_theme\_onOff\_mask\_android\_holo.png", onOffHandleDefaultFrame = sheetInfo:getFrameIndex("switch\_handle"), onOffHandleOverFrame = sheetInfo:getFrameIndex("switch\_handleOver"), onOffOverlayFrame = sheetInfo:getFrameIndex("switch\_overlay"), }) sceneGroup:insert(testSwitch) --standard design: local testSwitch1 = widget.newSwitch( {x = 200, y = 250, onPress = onSwitchPress,} ) local testSwitch2 = widget.newSwitch( {x = 200, y = 300, onPress = onSwitchPress,} )
Does someone has any hints for me? Thanks