You have to change it in ImageButton
's style and convert your Texture
to Drawable
using TextureRegionDrawable
:
// load your texture:
Texture newImage = new Texture(Gdx.files.internal("biggerImage.png"));
// get button's style
ImageButtonStyle style = myButton.getStyle();
Drawable drawable = new TextureRegionDrawable(new TextureRegion(newImage));
style.imageUp = drawable;
style.imageDown = drawable;
Done!
@Edit
new TextureRegionDrawable
won't allocate memory, because we pass an existing 'newImage' texture to it's constructor, BUT - it's a bad programming practice to make objects in places like render()
, resize()
etc. To do this right, declare two Textures
at the start of your screen, big and small one, declare two Drawables
, also at the start and load them via new TextureRegionDrawable
and then in resize()
put only:
if(screenSizeIsBig){ // your condition for big screen size
style.imageUp = bigDrawable;
style.imageDown = bigDrawable;
}else{ //
style.imageUp = smallDrawable;
style.imageDown = smallDrawable;
}