Search code examples
javalibgdxscrollpane

Libgdx Scrollpane doesnt scroll enough after widgets in the table (that owns a scroll pane) was moved


I have a question. Libgdx Scrollpane doesnt scroll enough after widgets in the table (that owns a scroll pane) was moved.

Here is the sample from my code.

Table scrollPaneTable = new Table();
Scrollpane itemsScrollPane = new ScrollPane(scrollPaneTable);
...
mainTable.add(itemsScrollPane).width(WIDTH).height(HEIGHT);
...
//adding items in the scrollPaneTable
// everything is work perfect at this moment.
....
for (final Actor actor : scrollPaneTable.getChildren()) {
...
actor.moveBy(MAIN_QUEST_ITEM_WIDTH * chapterData.quests.size * direction, 0);
...
}
...
//after I move actor in the table, scrollpane scrolls like before, I can't reach the last items.

Thanks for your help.


Solution

  • If anyone having this problem, I want to say, that I already resolved it a long time ago :D I understood how the scrollpane code works, then understood that I need to change maxX value, but it was private. So, I copied the full code of Scrollpane class to my project, created MyScrollPane.java.

    Then I added this to methods, in order to change maxX and maxY from outside of class.

        public void maxXBy(float x){
            this.maxX += x;
        }
    
        public void maxYBy(float y){
            this.maxY += y;
        }
    

    Then, in my main code, I played with those values and got the expected result.

    Thanks.