Search code examples
javaandroidlibgdx

Libgdx: how to remove the border in the table


I create the menu button in the table. I did not point anywhere in the border the table but it is displayed. I ran in the emulator or in desktop mode border appears maybe I create the wrong table?

@Override
    public void show() {
        table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

//Button PLAY
        //скин кнопки плай
        btnplayStyle = new ImageButton.ImageButtonStyle();
        btnplayStyle.up = buttonsSkin.getDrawable("play");//кнопка не нажата
        btnplayStyle.over = buttonsSkin.getDrawable("play");
        btnplayStyle.down = buttonsSkin.getDrawable("play"); // кнопка нажата
        playSkin = new ImageButton(btnplayStyle);
        playSkin.setSize(300, 200);

        stage.addActor(playSkin);
        playSkin.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                game.setScreen(new GameScreen(game));
            }
        });

        //Button score
        btnscoreStyle = new ImageButton.ImageButtonStyle();
        btnscoreStyle.up = buttonsSkin.getDrawable("records");//кнопка не нажата
        btnscoreStyle.over = buttonsSkin.getDrawable("records");
        btnscoreStyle.down = buttonsSkin.getDrawable("records"); // кнопка нажата
        scorebutton = new ImageButton(btnscoreStyle);
        scorebutton.setSize(300, 200);

        stage.addActor(scorebutton);
        scorebutton.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {

                game.setScreen(new Score(game) {

                });

            }
        });

        //Button EXIT
        btnexitStyle = new ImageButton.ImageButtonStyle();
        btnexitStyle.up = buttonsSkin.getDrawable("exit");//кнопка не нажата
        btnexitStyle.over = buttonsSkin.getDrawable("exit");
        btnexitStyle.down = buttonsSkin.getDrawable("exit"); // кнопка нажата
        exxitbutton = new ImageButton(btnexitStyle);
        exxitbutton.setSize(300, 200);

        stage.addActor(exxitbutton);
        exxitbutton.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                Gdx.app.exit();
            }
        });


        // table.add(heading);


        table.add(playSkin).width(400).height(100);
        table.getCell(playSkin).spaceBottom(30);
        table.row();


        table.add(scorebutton).width(400).height(100);

        table.getCell(scorebutton).spaceBottom(30);
        table.row();

        table.add(exxitbutton).width(400).height(100);
        table.getCell(exxitbutton).spaceBottom(30);
        table.row();
        table.debug();
        stage.addActor(table);
    }

in the emulator or in desktop mode border appears

After the start button will work properly, in the middle, but the border on each side as well created en understand because of what


Solution

  • The problem is that at the very end of your code you have :

    table.debug();
    

    Which according to the LibGDX Scene2d.ui documentation (https://github.com/libgdx/libgdx/wiki/Scene2d.ui)

    "enables debug lines for tables"

    So, simply just remove that line of code and it should work!