Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LibGDX physical scroll bar ScrollPane

Tags:

libgdx

I have created a ScrollPane but there is no bar to scroll with (like the one on the side of your browser) you have to drag with your mouse. How can I get a scroll bar?

like image 728
dan14941 Avatar asked Jan 14 '15 16:01

dan14941


1 Answers

What I did to add a scrollbar was use libgdx's ScrollPane.ScrollPaneStyle to set the scroll bar as a ninepatch.

ScrollPane.ScrollPaneStyle scrollStyle;
/...

scrollTexture = new Texture(Gdx.files.internal("Scroll9.png"));
scrollNine = new NinePatch(new TextureRegion(scrollTexture,6,6),2,2,2,2);

then I created the vertical scroll knob

scrollStyle = new ScrollPane.ScrollPaneStyle();
scrollStyle.vScrollKnob = new NinePatchDrawable(box);

and applied the style to my scrollable table

scroll = new ScrollPane(test, scrollStyle);

source: http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ScrollPane.ScrollPaneStyle.html

like image 123
dan14941 Avatar answered Oct 13 '22 05:10

dan14941