TItanium Android Scrollview不可滚动

时间:2012-06-28 08:08:13

标签: android titanium scrollview

我有滚动视图问题但它对我不起作用。即使我已经读过scrollview内容宽度和高度'auto'有一个bug,我已经将它缩放到一个很大的值,它不会向下滚动我的内容。以下是我目前的代码。

var scrollView = Titanium.UI.createScrollView({
    contentWidth:'300',
    contentHeight:'2000',
    top:0,
    showVerticalScrollIndicator:true,
    showHorizontalScrollIndicator:true
});
var view = Ti.UI.createView({
    backgroundColor:'#336699',
    borderRadius:10,
    width:300,
    height:2000,
    top:10
});
scrollView.add(view);

var timePickerWin = Ti.UI.createWindow({
            navBarHidden : true,
            backgroundColor : '#fff'
        });


var label = Ti.UI.createLabel({ 
   text:'Pick Up Detail Form', 
   font: {fontFamily: 'Verdana', fontSize:30}, 
   color: '#000',
   top : '15dp'
});

var label2 =Ti.UI.createLabel({
    text:'Enter Your Pickup Details Below',
    font: {fontFamily: 'Verdana', fontSize:12}, 
    color: '#000',
    top : '50dp'
})


var startTime = Ti.UI.createPicker({
        top : '335dp',
        left : '25dp',
        useSpinner : false,
        selectionIndicator : true,
        type : Ti.UI.PICKER_TYPE_TIME,
        format24 : false,
        height : '130dp',
        //  width:'auto'

    });


 var startDate = Ti.UI.createPicker({
            top : '200dp',
            left : '25dp',
            useSpinner : false,
            selectionIndicator : true,
            type : Ti.UI.PICKER_TYPE_DATE,
            format24 : false,
            height : '130dp'
        });

var nextButton = Ti.UI.createButton({
            width : '150dp',
            height : '45dp',
            top : '465dp',            
            title : 'Next',
            backgroundColor : '#294079',
            font : {
                fontSize : '18dp',
                fontWeight : 'bold'
            },
            color : '#fff'
        });


nextButton.addEventListener('click', function() {
        timePickerWin.hide();
    });


startTime.addEventListener('change', function(e) {
        //alert("User selected date: " + e.value);
        startPickerValue = e.value;
    });

    startDate.addEventListener('change', function(e) {
        //alert("User selected date: " + e.value);
        endPickerValue = e.value
    });

var fullNameTextBox = Ti.UI.createTextField({
        borderStyle : Titanium.UI.INPUT_BORDERSTYLE_ROUNDED,
        width : '275dp',
        height : '45dp',
        //value : '',
        top : '75dp',
        color : '#000000',
        hintText : 'Enter full name'
        //  backGroundColor:'gray',

    });

    var addressTextBox= Ti.UI.createTextField({
        borderStyle : Titanium.UI.INPUT_BORDERSTYLE_ROUNDED,
        width : '275dp',
        height : '45dp',
        //value : '',
        top : '117dp',
        color : '#000000',
        hintText : 'Enter Address'

    });

        var MobileNo = Ti.UI.createTextField({
        borderStyle : Titanium.UI.INPUT_BORDERSTYLE_ROUNDED,
        width : '275dp',
        height : '45dp',
        //value : '',
        top : '155dp',
        color : '#000000',
        hintText : 'Enter Mobile No.'
        //  backGroundColor:'gray',

    });

timePickerWin.add(scrollView);
timePickerWin.add(label);
timePickerWin.add(label2);
timePickerWin.add(MobileNo);
timePickerWin.add(startTime);
timePickerWin.add(startDate);
timePickerWin.add(addressTextBox);
timePickerWin.add(fullNameTextBox);
timePickerWin.add(nextButton); 


timePickerWin.open()

1 个答案:

答案 0 :(得分:1)

您需要将滚动视图的所有内容添加到滚动视图中。

更改这些行:

timePickerWin.add(scrollView);
scrollView.add(label);
scrollView.add(label2);
scrollView.add(MobileNo);
scrollView.add(startTime);
scrollView.add(startDate);
scrollView.add(addressTextBox);
scrollView.add(fullNameTextBox);
scrollView.add(nextButton); 

希望这对你有用。