Scroll window without using scrollView and Control back button operation.

You must Login before you can answer or comment on any questions.

Hi, I wonder is there any alternate way to scroll the window without using the ScrollView. This need raised to me as I am having so many issues in using the ScrollView. I am adding my controls to a view and adding that view to the scrollView but it changes the size of all of my UI controls from the specified sizes. I am doing it in this way. Please guide me where I am wrong:-

var scrol=Titanium.UI.createScrollView({
        width: 320,
        height: Titanium.UI.SIZE,
        contentHeight: 'auto',
        contentWidth:'auto',
        scrollType: 'vertical',
        showVerticalScrollIndicator: true
    });
var view=Ti.UI.createView();
view.add(...);
... //add all controls to view.
scrol.add(view);
win.add(scrol);
win.open();
Also can anyone tell that how to control the back button operation in Android. I want to navigate to the previous screen but it closes the application when I press the back button. I am using Android 2.2 and Titanium 2.0.2. Any help in this regard would be greatly appreciated. Thanks.

1 Answer

Hi Muhammad Qasim Khan,

For back button in android you need to open window as modal like below code.

var winNew = Ti.UI.createWindow({
                url : 'url.js',
                title : 'MyWin'
            });
            winNew.open({
                modal : true
            });
or you have to open it in your tabgroup like this way.
var winNew = Ti.UI.createWindow({
                url : 'url.js',
                title : 'MyWin'
            });
Ti.UI.currentTab.open(winNew);
and for scrolling problem you have to set fix height for scrollview like height:420 or as per your requirement.

Best luck

— answered 11 months ago by Nitin Chavda
answer permalink
7 Comments
  • Thanks for your quick response Nitin. So there is no other way to scroll without using ScrollView and is mentioning the window url necessary for modal OR I can skip it. Thanks.

    — commented 11 months ago by Muhammad Qasim Khan

  • Can you tell us what data you are filling in view?.

    — commented 11 months ago by Nitin Chavda

  • These are 5 UI Controls. 2 buttons and 3 labels. I just skipped the view and it works fine with scrollview also but now the problem is that scrollview doesn't shows the contents till end. For example if add 3 buttons and 3 labels, it shows 2 button n labels fine but 3rd button is half shown and half out of the screen and the 3rd label is full out of the screen. I've tried my best but no use...

    — commented 11 months ago by Muhammad Qasim Khan

  • Show 4 more comments

Your Answer

Think you can help? Login to answer this question!