0
我遇到問題讓libgdxs scrollpane控件工作。下面的代碼顯示了帶有標籤的簡單佈局的控制設置,滾動窗格內的項目列表以及按鈕。問題是我的滾動窗格沒有顯示除vScroll/vScrollKnob ninepatch(那個小白色方塊) 以外的其他東西,它看起來像這樣:libgdx scrollpane不顯示
private void setupLayout()
{
String[] listEntries = {"1","2","3","4","5"};
ListStyle listStyle = new ListStyle();
NinePatch example = new NinePatch(new Texture(Gdx.files.internal("data/example.9.png")));
listStyle.selectedPatch = example;
listStyle.font = new BitmapFont();
mList = new List(listEntries,listStyle);
ScrollPaneStyle paneStyle = new ScrollPaneStyle();
paneStyle.vScroll = example;
paneStyle.vScrollKnob = example;
mListScroll = new ScrollPane(mList,paneStyle);
mListScroll.setScrollingDisabled(true, false);
mListScroll.width = 500;
mListScroll.height = 500;
LabelStyle ls = new LabelStyle();
ls.font = new BitmapFont();
ls.fontColor = new Color(1.0f, 1.0f, 1.0f, 1.0f);
mLabel = new Label("Label", ls);
TextButtonStyle buttonStyle = new TextButtonStyle();
buttonStyle.font = new BitmapFont();
mButton = new TextButton("Button",buttonStyle);
Table table = new Table();
table.add(mLabel);
table.row();
table.add(mButton);
table.row();
table.add(mListScroll);
mStage.addActor(table);
}
它工作正常,如果我不使用該滾動窗格和直接添加列表,表是這樣的:
Table table = new Table();
table.add(mLabel);
table.row();
table.add(mButton);
table.row();
table.add(mList); //changed mListScroll(scrollpane class) to mList(List class)
mStage.addActor(table);
但隨後它會伸出當物品太多時,我的屏幕底部。我在這裏做錯了什麼?我需要在scrollpane上設置另一個參數嗎?