java - How to change the color of the background in libgdx labels? -


i can change color of font this

labelstyle style1 = new labelstyle(..some font...,                  color.valueof("ff4500")                 ); label.setstyle(style1); 

but how change background? right background same background of whole screen set in

render method lke

gdx.gl.glclear(gl10.gl_color_buffer_bit);     gdx.gl.glclearcolor(             1.000f, 0.980f, 0.941f              ,1); 

actually not change background of lable that. did change clearcolour. guess know that.

to change background need change background @ style of label. i'd recommend use simple ninepatch background, (can square! if white can change colour of ninepatch , background colour changes!)

ninepatch temp = new ninepatch(new texture(....), 10, 10, 10, 10); //edges 

for more information ninepatch take here libgdx wiki ninepatch

you need add ninepatch skin objekt. example this

skin skin = new skin(); skin.add("background",temp) 

after can drawable skin can set background of labelstyle.

style1.background = skin.getdrawable("background"); 

see libgdx api labelstyle

you can use simple bitmap scaled label size causes in of cases deformation. ninepatch can scaled without having deformation.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -