Java 如何在libgdx中创建没有标题栏的窗口

Java 如何在libgdx中创建没有标题栏的窗口,java,libgdx,Java,Libgdx,我有一个项目需要如下所示: 使用window我得到以下结果 我用以下代码创建上述结果 private Table buildControlsWindowLayer() { Window window = new Window("", skinLibgdx); // + play button playButton = new Button(maputoSkin, "play"); window.add(playButton).p

我有一个项目需要如下所示:

使用window我得到以下结果

我用以下代码创建上述结果

private Table buildControlsWindowLayer() {
        Window window = new Window("", skinLibgdx);
        // + play button
        playButton = new Button(maputoSkin, "play");
        window.add(playButton).pad(10, 0, 10, 0).row();
        playButton.addListener(listener);
        // + options button
        optionsButton = new Button(maputoSkin, "options");
        window.add(optionsButton).pad(10, 0, 10, 0).row();
        optionsButton.addListener(listener);
        // + leaders button
        leadersButton = new Button(maputoSkin, "leaders");
        window.add(leadersButton).pad(10, 0, 10, 0).row();
        leadersButton.addListener(listener);
        if (Constants.DEBUG_FLAG_MENU_SCREEN) window.debug();
        window.pack();
        window.setPosition(Constants.VIEWPORT_GUI_WIDTH / 2 - window.getWidth()/2,
                           Constants.VIEWPORT_GUI_HEIGHT/2 - window.getHeight());
        return window;
    }
我的问题

我怎样才能摆脱标题栏

二,。如何设置自己的背景而不是libgdx默认设置


三、 这种方法适用于第三种情况吗?

Window(java.lang.String title,Window.WindowStyle样式) 还有一个
setStyle(Window.WindowStyle样式)
方法。
Window.WindowStyle
类允许您定义此窗口的样式,包括背景。()

根据libgdxs doc,对于标题栏,窗口是:

“一个可以拖动并充当模式窗口的表。顶部填充用作窗口的标题高度。”,我没有找到任何直接的方法来摆脱标题栏,但是如果扩展window类,可以覆盖它的一些功能以获得所需的结果。查看其来源:


要回答第三个问题,你必须提供更多信息,在这种情况下你的意思是什么

我的方法是使用表格而不是窗口,并将其背景定义为可从皮肤上绘制的ninepatch

private Table buildControlsWindowLayer() {
        SpriteDrawable bgDrawble=new SpriteDrawable(new Sprite(createTexture(120, 400, Color.BLACK, 1)));
        WindowStyle windowStyle=new WindowStyle(new BitmapFont(), Color.GREEN, bgDrawble);
        Window window = new Window("", windowStyle);
       // window.setWidth(0);
        // + play button
        SpriteDrawable upDrawble=new SpriteDrawable(new Sprite(createTexture(100, 40, Color.RED, 1)));
        SpriteDrawable downDrawble=new SpriteDrawable(new Sprite(createTexture(100, 40, Color.RED, 1)));
        SpriteDrawable cheDrawble=new SpriteDrawable(new Sprite(createTexture(100, 40, Color.RED, 1)));
        TextButtonStyle btStyle=new TextButtonStyle(upDrawble, downDrawble, cheDrawble, new BitmapFont());
        TextButton playButton = new TextButton("play",btStyle);
        window.add(playButton).pad(10, 0, 10, 0).row();
        //playButton.addListener(listener);
        // + options button
        TextButton  optionsButton = new TextButton( "options",btStyle);
        window.add(optionsButton).pad(10, 0, 10, 0).row();
       // optionsButton.addListener(listener);
        // + leaders button
        TextButton  leadersButton = new TextButton("leaders",btStyle);
        window.add(leadersButton).pad(10, 0, 10, 0).row();
        //leadersButton.addListener(listener);
       /// if (Constants.DEBUG_FLAG_MENU_SCREEN) window.debug();
        window.pack();
       // window.getTitleTable() ;
        return window;
    }



public static Texture createTexture(int width, int height, Color col,
            float alfa) {
        Pixmap pixmap = new Pixmap(width, height, Format.RGBA8888);
        Color color = col;
        pixmap.setColor(color.r, color.g, color.b, alfa);
        pixmap.fillRectangle(0, 0, width, height);

        Texture pixmaptexture = new Texture(pixmap);
        return pixmaptexture;
    }
    Skin skin = SkinManager.getInstance().getSkin();
    final Table outerTable = new Table();
    outerTable.setFillParent(true);
    stage.addActor(outerTable);

    // Layer to hold the buttons and dark background
    Table buttonsTable = new Table();

    playButton = new TextButton("Play", skin, "play");
    settingsButton = new TextButton("Setting", skin, "setting");
    highScoreButton = new TextButton("Leaders", skin, "leaders");

    buttonsTable.add(playButton).width().height().pad();
    buttonsTable.row();
    buttonsTable.add(settingsButton).width().height().pad(0);
    buttonsTable.row();
    buttonsTable.add(highScoreButton).width().height().pad();
    buttonsTable.row();
    // + background color
    buttonsTable.setBackground(controlsBackground);

    // Adding button table to outer table
    outerTable.add(buttonsTable).colspan(2).expand();
我将
width()
height()
pad()
留空,因为它们取决于你的世界大小。 还有一件事

controlsBackground = new NinePatchDrawable(new NinePatch(
                SkinManager.getInstance().getSkin().getRegion("menu-background"), 10, 10, 10, 10
        ));