我制作了.pack文件并加载到皮肤。我可以将它设置为可绘制的图像类,它工作正常。但Table.setBackground
什么都不做。Libgdx表setBackground什么也不做
Drawable background = skin.getDrawable("tooltip_background");
tooltipGroup.setBackground(background);
为什么这段代码不工作?
全码:
tooltipGroup = new Table(skin);
tooltipGroup.setWidth(w/6);
Label.LabelStyle headerStyle = new Label.LabelStyle(headerFont, Color.GREEN);
Label headerLabel = new Label(effect.getName(), headerStyle);
headerLabel.setWidth(w/6);
headerLabel.setX(20);
headerLabel.setWrap(true);
headerLabel.setAlignment(Align.topLeft);
tooltipGroup.addActor(headerLabel);
Label.LabelStyle style = new Label.LabelStyle(font, Color.WHITE);
Label descriptionLabel = new Label(effect.getDescription(), style);
descriptionLabel.setWidth(w/6);
descriptionLabel.setWrap(true);
descriptionLabel.setAlignment(Align.topLeft);
descriptionLabel.setPosition(20, -descriptionLabel.getHeight());
tooltipGroup.addActor(descriptionLabel);
tooltipGroup.setPosition(mouseX, h - mouseY);
Drawable background = skin.getDrawable("tooltip_background");
tooltipGroup.setBackground(background);
stage.addActor(tooltipGroup);
我发现有什么问题。在init中,表的宽度和高度= 0。并且...将具有它们自己尺寸的项目添加到Table中,不会改变Table的宽度和高度。为什么?我如何处理这个问题,如果带'setWrap(true)'的标签只返回一行的高度? –
粘贴构建表格的完整代码,并将其添加到场景中。不添加最小宽度/高度的演员不会自动填充场景,因此要么设置最小宽度/高度,要么将其设置为填充整个场景。 – Bernd
@Bernd检查完整代码的问题。 和...如果我设置最小的宽度/高度,比表将使用它?好。但是,内容的实际宽度和高度显着超过理论上选择的最小值。 –