Reputation: 105
My scrollPane is not scrolling when i add ScrollPaneStyle, does anyone know why is happinging?
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);
Upvotes: 3
Views: 2365
Reputation: 59
I met the same problem as you did.
when I add the scroll panel to a Table, it can scroll as I 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);
You can refer the test code from libgdx test also.
Upvotes: 1
Reputation: 59
after you init the scrollpane you should call this first
mScrollPane.layout();
Upvotes: 1