Use felt listView

et listView = new ccui.ListView();
this.addChild(listView,9999);
listView.setDirection(ccui.ScrollView.DIR_VERTICAL);
listView.setTouchEnabled(true);
listView.setContentSize(cc.size(width,height));
listView.setScrollBarEnabled(false);
listView.setItemsMargin(0);

let layout = new ccui.Layout();
layout.setContentSize(cc.size(listView.width,listView.height/2));
listView.pushBackCustomItem(layout);//而非addChild

let labelTTF = new cc.LabelTTF('testString');
layout.addChild(labelTTF);
labelTTF.setPosition(layout.width/2,layout.height/2);

let imageView = new ccui.ImageView();
listView.pushBackCustomItem(imageView);//listView只能push进去ccui控件

Guess you like

Origin www.cnblogs.com/guomengkai/p/12029222.html