Same Problem:
Label wrap and Scrolling the ScrollPane (http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=11089&p=49905&hilit=ScrollPane#p49905)
How do I move to the last inserted Label?
I try this.scrollTo(0, 0, 0, 0);, no work corretly, See the figure below:
Note: I try too setScrollX and setScrollY but it doesn’t work.
MySource:
public class LogScrollPane extends ScrollPane {
private static Table log = new Table();
private final int MAX_SIZE = 10;
public LogScrollPane(Skin skin) {
super(log, skin);
//clear();
this.setScrollingDisabled(false, false);
//this.setForceScroll(false, true);
log.align(Align.left);
}
public void add(Label label) {
log.add(label);
log.row();
updateList();
this.scrollTo(0, 0, 0, 0);
this.invalidate();
}
public void updateList(){
int count = log.getChildren().size;
int result = count-MAX_SIZE;
if (result>0){
for (int a=0;a<result;a++){
log.removeActor(log.getChildren().get(a));
}
}
}
public void clear() {
log.clear();
this.invalidate();
}
}
Found that when the method is executed below (updateList ()), it does what it should, displaying the last added.
Note Remember that it ta displaying the penultimate added.
public void updateList () {
int count = log.getChildren () size.;
int result = count-MAX_SIZE;
if (result> 0) {
for (int a = 0, the <result, the + +) {
log.removeActor (log.getChildren () get (a).);
}
}
}