I have developed a sample code in which I created a widget having just a view which adds image view inside it. It works perfect when I apply styles from tss of controller directly but when "formFactor" is used it's not working. To clarify the same please check code placed here.
You can create a new Alloy Project and test the same with following code:
NOTE: All dependencies are included in config.json
Widget Implementation:
widget.xml
<Alloy>
<View id="section" class="section"></View>
</Alloy>
widget.tss
".section":{
backgroundColor: 'red',
layout : 'vertical'
},
widget.js
var args = arguments[0] || {};
$.section.applyProperties(args);
$.setData = function(view) {
$.section.add(view);
}
Coding for Index page
Index.xml
<Alloy>
<ScrollView class="baseView">
<Widget id="contentView" class="contentView" src="com.investis.scrollablesection"></Widget>
</ScrollView>
</Alloy>
Index.tss
".contentView [formFactor=handheld]":{
backgroundColor: 'green',
width: Ti.UI.FILL,
height: Ti.UI.SIZE
}
Index.js
var imgView = Ti.UI.createView({
backgroundColor: 'yellow',
top: 20,
left: 0,
right: 0,
width: Ti.UI.FILL,
height: Ti.UI.SIZE
});
$.contentView.setData(imgView);
The same thing works if I remove [formFactor=handheld]
from .contentView
in Index.tss