2013-04-07 65 views
3

我的scrollPane不滚动时,我添加ScrollPaneStyle,有谁知道为什么happinging?Libgdx scrollPane没有滚动后,我添加了scrollPaneStyel

scroller = new ScrollPane(myWidget , skin); 
     scroller.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); 
     this.addActor(scroller); 
     scroller.setLayoutEnabled(true); 
     scroller.setCancelTouchFocus(true); 
     ScrollPaneStyle paneStyle = new ScrollPaneStyle(); 
     Texture tex = new Texture(Gdx.files.internal(filepath + "page.png")); 
     tex.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.ClampToEdge); 
     paneStyle.background = new SpriteDrawable(new Sprite(tex)); 

     scroller.setScrollbarsOnTop(true); 
     scroller.setStyle(paneStyle); 

回答

1

你初始化滚动面板之后,你应该把这个第一

mScrollPane.layout(); 
1

像你一样我遇到了同样的问题。

当我添加滚动面板到一个表,它可以滚动,因为我exptected。

ScrollPane pane2 = new ScrollPane(mytable, style); 
style.background = new TextureRegionDrawable(scrollAtalas.findRegion("default-rect")); 
pane2.setScrollingDisabled(false, true); 
pane2.setSize(w, h); 
final Table table = new Table(); 
table.setFillParent(true); 
table.add(pane2).fill(); 

stage.addActor(table); 

您可以从libgdx test也指测试代码。

3

在绘制舞台后,您必须添加stage.act();以进行渲染。