【发布时间】:2016-02-10 17:53:17
【问题描述】:
我有一个HorizontalGroup,其中有两个文本按钮。现在我想将这些按钮缩放到它们的一半大小,因为它们太大了,但我还没有找到一个好的方法来做到这一点,我尝试了一些方法,但它不是我想要的。
下面是设置代码
weaponsButton = new TextButton("Weapons", buttonStyle);
weaponsButton.getLabel().setColor(Color.BLACK);
weaponsButton.pad(10f);
statsButton = new TextButton("Stats", buttonStyle);
statsButton.getLabel().setColor(Color.BLACK);
statsButton.pad(10f);
hGroup = new HorizontalGroup();
hGroup.addActor(weaponsButton);
hGroup.addActor(statsButton);
table = new Table();
table.add(hGroup);
table.setFillParent(true);
table.debug();
stage = new Stage();
stage.addActor(table);
buttonStyle 只是一个TextButtonStyle 与一个NinePatchDrawable 和一个BitmapFont。当您绘制表格时,它看起来像这样:
添加hGroup.setScale(0.5f); 看起来像这样:
现在hGroup 未居中对齐,.aling(Align.center) 在添加 hGroup 时不执行任何操作。
在添加hGroup 以缩小单元格之后调用.width(float) 似乎也没有用,因为我不知道缩放hGroup 的确切宽度,它只给出未缩放的宽度,我觉得它有点笨重得到宽度,然后乘以缩放因子。
即使我这样做了,它看起来也不是我想要的。
table.add(hGroup).width(hGroup.getPrefWidth()*0.5f).height(hGroup.getPrefHeight()*0.5f);
看起来像这样:
感谢任何建议
【问题讨论】:
标签: java user-interface libgdx scene2d