0
votes

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

1
SDK: 3.2.1, iOS: 7, in simulator, not working formFactorParesh Thakor

1 Answers

0
votes

Missing from your answer are some critical details, like what platform are you building for, what version of the Titanium SDK you're using, and you're not clear about what you expect compared to what you see as the problem.

Using your code, building for the iOS Simulator, I get a green scrollview filling the width of the screen, and roughly 20dp high -- with or without the [formFactor=handheld] qualifier on the index.tss class. If I increase the height of the scrollview I see a yellow view within. So, what's the problem?