by
2
7
1,765
4
Top 1% !
Popular
Famous
Tagged
Specified
Tuned
OpenSource
Created
Modified Sep 27, 2017

Published on:

FrameworklibGDX
InputName0red
InputName1green
InputName2blue
InputName3alpha
InputType0int
InputType1int
InputType2int
InputType3int
Languagecsharp
Languagejava
LicenseMIT_X11
MethodNamesetBackgroundColor
OutputTypevoid

Setting the libGDX Table background color

A quick and less custom way.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/2826977/Setting-the-libGDX-Table-background-colo?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
/* * It costs less to use a TextureRegion; however, to simplify the example, * a whole separate Texture is used here. */ Table table; Texture whiteTexture; Sprite bgSprite; public void setBackgroundColor(int red, int green, int blue, int alpha) { // keep a reference to the Texture, so that it can be disposed later whiteTexture = new Texture(Gdx.files.internal("white_color_texture.png")); bgSprite = new Sprite(whiteTexture); bgSprite.setColor(red/255f, green/255f, blue/255f, alpha/255f); table.setBackground(new SpriteDrawable(bgSprite)); } // ... public void disposeTexture() { whiteTexture.dispose(); } /* * An example of what's meant by "white_color_texture.png": * https://github.com/ronrihoo/libGDX-Table-Background-Color/blob/master/white_color_texture.png */
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus