简体   繁体   中英

libGDX - How to fill Table to Cell size?

I want to make sub Table in a Cell to fill to that cell as a parent.

    // Main Table
    Table mainTable = new Table();

    // Sub Table
    Table subTable = new Table();

    mainTable.add(        ).expand().row(); // cell-1

    mainTable.add(subTable).expand().row(); // cell-2

    mainTable.add(        ).expand().row(); // cell-3

The Code result:

在此处输入图片说明

When I make subTable.setFillParent(true) , it will fill to mainTable . Ok its well.

在此处输入图片说明

But I want to make subTable fill to expand size of the cell-2 .

I mean:

在此处输入图片说明

How can I make this?

Check LibGDX wiki: https://github.com/libgdx/libgdx/wiki/Table#fill

The fill method causes a widget to be sized to the cell. Like expand, there are also fillX and fillY methods.

 table.add(nameLabel).expand().bottom().fillX(); 

...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM