can I covered toolbar with ScrollView?

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

can I covered toolbar with ScrollView? I try it, but It's not work. what problem with my code. thank you

Titanium.UI.setBackgroundColor('#fff');
 
var win = Titanium.UI.createWindow({
    title: 'Tab 1',
    backgroundColor: '#fff'
});
 
var send = Titanium.UI.createButton({
        title: 'Send',
        style: Titanium.UI.iPhone.SystemButtonStyle.DONE,
    });
 
var camera = Titanium.UI.createButton({
    systemButton: Titanium.UI.iPhone.SystemButton.CAMERA,
});
 
var cancel = Titanium.UI.createButton({
    systemButton: Titanium.UI.iPhone.SystemButton.CANCEL
});
 
var btn = Ti.UI.createButton(
    {
        width: 50, height: 40, 
        backgroundImage :'btn11.png',
        backgroundFocusedImage: 'btn11.png',
        backgroundSelectedImage: 'btn11.png'
    }
);
 
 
flexSpace = Titanium.UI.createButton({
    systemButton:Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE
});
 
var sclView = Titanium.UI.createScrollView(
    {
        width:1000,
        height:40,
        top:30,
        left:0,
    showHorizontalScrollIndicator: true,
    }
)
var toolbar = Titanium.UI.iOS.createToolbar({
    items:[send, camera,btn, flexSpace, cancel,btn,btn],
    bottom:0,
    borderTop:true,
    borderBottom:false,
    top:0
}); 
sclView.add(toolbar);
win.add(sclView);
 
win.open();

1 Answer

Accepted Answer

Hi Chang,

You need to set height,width of toolBar or you need to set contentHeight,contentWidth of scrollview. Try below code.

var toolbar = Titanium.UI.iOS.createToolbar({
    items : [send, camera, btn, flexSpace, cancel, btn, btn],
    borderTop : true,
    borderBottom : false,
    top : 0,
    height : 40,
    width : 320,
    left : 0
});

— answered 10 months ago by Nitin Chavda
answer permalink
4 Comments
  • I add width and height in toolbar, but the toolbar can't scroll . there are show content on toolbar, but can't scroll. Is it can scroll ? thank you very much

    — commented 10 months ago by Chang YuanYu

  • Hi Chang,

    By default toolbar get width of 320 if you want to scroll horizontal then you have to set property for scrollview i.e. scrollType:'horizontal' and also try to set toolbar width.

    var sclView = Titanium.UI.createScrollView({
        width : 320,
        height : 40,
        top : 30,
        contentWidth : 'auto',
        left : 0,
        showHorizontalScrollIndicator : true,
        scrollType:'horizontal'
    })
    var toolbar = Titanium.UI.iOS.createToolbar({
        items : [send, camera, btn, flexSpace, cancel, btn, btn],
        bottom : 0,
        borderTop : true,
        borderBottom : false,
        top : 0,
        width : 400
    });
    sclView.add(toolbar);

    — commented 10 months ago by Nitin Chavda

  • oh~!! I have not set scrollType!! thank you very much, Nitin Chavda. thank you are very enthusiastic, thank you.!

    — commented 10 months ago by Chang YuanYu

  • Show 1 more comment

Your Answer

Think you can help? Login to answer this question!