# LibGDX - Ordentliche Größenänderung



## Lucaaa (22. Mrz 2019)

Hallo.

Ich habe Textbuttons (3) die in einer VerticalGroup angeordnet sind. Jetzt möchte ich die größe der Buttons ädern. Ich habe es mit setScale() versucht aber dann ragen die Buttons aus dem Bildschirm. Wenn ich die origin in die Mitte des Buttons setze, bleibt er zwar im Bild, aber die Buttons sind dann nicht mehr gleich groß.

Was kann ich da machen?


```
private void initUI() {
   fontButton =new BitmapFont(Gdx.files.internal("ui/fonts/segoe-script.fnt"));
   
   
   // get width and height for viewport and set camera
   final int WIDTH = Gdx.graphics.getWidth();
   final int HEIGHT = Gdx.graphics.getHeight();
   cam =new OrthographicCamera(1, HEIGHT/WIDTH);
   stage =new Stage();
   stage.getCamera().position.set(WIDTH/2, HEIGHT/2, 0);
   
   Gdx.input.setInputProcessor(stage);
   batch =new SpriteBatch();
   skin =new Skin(Gdx.files.internal("ui/uiskin.json"));
   // ui group containing the ui elements
   VerticalGroup buttonGroup =new VerticalGroup();
   buttonGroup.setFillParent(true);
   buttonGroup.align(Align.right);
   
   buttonGroup.space(50f);
   
   // config ui elements
   
   TextButtonStyle textButtonStyle =new TextButtonStyle();
   textButtonStyle.up = skin.getDrawable("default-round");
   textButtonStyle.font = fontButton;
   
   float btnScale =1f;
   btnPlay =new TextButton("Play Game", textButtonStyle);
   btnPlay.setTransform(true);
   btnPlay.setOrigin(btnPlay.getWidth(), btnPlay.getHeight()/2);
   btnPlay.setScale(btnScale);
   btnPlay.pad(5);
   btnPlay.setColor(Color.WHITE);
   btnOptions =new TextButton("Options", textButtonStyle);
   btnOptions.pad(5);
   btnOptions.setTransform(true);
   btnOptions.setOrigin(btnOptions.getWidth(), btnOptions.getHeight()/2);
   btnOptions.setScale(btnScale);
   btnOptions.setColor(Color.WHITE);
   btnExit =new TextButton("Exit Game", textButtonStyle);
   btnExit.setTransform(true);
   btnExit.setOrigin(btnExit.getWidth(), btnExit.getHeight()/2);
   btnExit.setScale(btnScale);
   btnExit.pad(5);
 
   // add ui elements to group and stage
   buttonGroup.addActor(btnPlay);
   buttonGroup.addActor(btnOptions);
   buttonGroup.addActor(btnExit);
   buttonGroup.padRight(50);
   buttonGroup.fill();
   stage.addActor(buttonGroup);
   buttonGroup.setTransform(true);
   buttonGroup.validate();
   
   
   
  }
```


----------



## JuKu (11. Apr 2019)

Ich glaube die Lösung lautet:

```
TextButton button = new TextButton("text", skin);
Container<TextButton> container = new Container<TextButton>(button);
container.width(150);
hGroup.addActor(container); 

//add container to your VerticalGroup
```

Du musst wohl einen Container drum herum bauen.
Quelle: https://www.badlogicgames.com/forum/viewtopic.php?f=11&t=22037


----------



## Lucaaa (18. Apr 2019)

Danke


----------

