Can anybody guide me, I am creating a table in libgdx game on menu screen to set different buttons on my screen. here is the code for table draw

 table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

and here is the code for background for this menu screen

batch.draw(bckTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

My bcktexture image size is 600 by 400.

Now this table draws in the middle of the screen. I dont understand this why. it should be drawn by 0 , 0 corner and fill the whole screen. I have checked table by table.debug();

what I want is that the table should cover the whole screen so that I can adjust my buttons anywhere on the screen i want especially at the corners.


2 Answers 2


The setBounds() method comes from the Actor class, which the Table class subclasses. It is usually used for stuff like collision detection, but not setting the size of your actors.

In your case, you can go as simple as calling table.setFillParent(true); to have your table fill up the entire space in its parent (btw, are you adding it to a stage or something?)

Otherwise, use the setSize() and setPosition() methods to explicitly set size and position of your table inside its parent.

You might also want to check out this tutorial on using tables in libGDX: TableLayout.

Hope this helps.

  • \$\begingroup\$ actually i was using stage as well but i was confused with setBounds as I thought it might give size to table. as Table always get draw in the center of the screen. but I used view port for stage and my problem solved. \$\endgroup\$ Jan 13, 2015 at 8:57
  • \$\begingroup\$ setSize() and setPosition() does the exact same thing as setBounds() but separately \$\endgroup\$
    – Winter
    Jan 7, 2017 at 21:33

Is your camera centered? If your camera is not centered, then it may be looking at (0, 0), which from your perspective is the center of the screen.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .