LibGDX Scene2d:如何向 ImageButton 添加一行?
LibGDX Scene2d: How to add a row to an ImageButton?
我知道我可以使用 ImageTextButton,但出于某种原因,我只想向 ImageButton 添加一行,它是 Table 的子项 class。
我这样试:
ImageButton btn = new ImageButton(skin, "style");
Label lb = new Label(text, skin);
btn.row();
btn.add(lb);
标签不是出现在图像下方,而是出现在图像旁边。
为什么 row()
不像常规 table 那样开始新行?
这是一个recent LibGDX bug。我认为您现在可以通过在添加新行之前添加一个空单元格来解决这个问题。像这样:
btn.add().row();
您可能需要在添加的下一个项目上使用 colspan(2)
以使其正确对齐。
我知道我可以使用 ImageTextButton,但出于某种原因,我只想向 ImageButton 添加一行,它是 Table 的子项 class。
我这样试:
ImageButton btn = new ImageButton(skin, "style");
Label lb = new Label(text, skin);
btn.row();
btn.add(lb);
标签不是出现在图像下方,而是出现在图像旁边。
为什么 row()
不像常规 table 那样开始新行?
这是一个recent LibGDX bug。我认为您现在可以通过在添加新行之前添加一个空单元格来解决这个问题。像这样:
btn.add().row();
您可能需要在添加的下一个项目上使用 colspan(2)
以使其正确对齐。