简体   繁体   中英

Scene2d ScrollPane not scrolling

I create a ScrollPane, with table inside. It works fine, but when I add this ScrollPane to layout Table (or VecrticalGroup) it stops working.

    layoutTable = new Table();
    groupTable = new Table();
    SP = new ScrollPane(groupTable, skin);
    SP.setWidth(1105);
    SP.setHeight(300);
    groupTable.top();
    groupTable.left();

    layoutTable.add(inputTable);
    layoutTable.row();
    layoutTable.add(SP);
    layoutTable.row();
    layoutTable.add(resultTable);
    layoutTable.setFillParent(true);
    stage.addActor(layoutTable);

Once you add it to the table, the table manages its size, so your earlier calls ( SP.setWidth() and SP.setHeight() ) are overwritten (probably with whatever is the prefSize of the scroll pane's contents, which is zero if it's an empty table). If you want to control the scroll pane's size, do it by adjusting its cell when you add it to the table:

layoutTable.add(SP).width(1105).height(300).fill();

The fill() call tells the table to resize the scroll pane to fit the cell dimensions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM