ImageButton doesn't show an image at center when background props: up, down are set.
supermaximus80 opened this issue · 6 comments
Issue details
ImageButton doesn't show an image when background props: up, down are set. The only possible way to show an image at center of an ImageButton is do not set background properties.
Reproduction steps/code
Create the style in uiskin.json
com.badlogic.gdx.scenes.scene2d.ui.ImageButton$ImageButtonStyle: {
default: { down: button3Up, up: button3Up, checked: button3Up, imageUp: beigeRefresh, imageDown: beigeRefresh, imageChecked: beigeRefresh, imageOver: beigeRefresh },
button1: { up: button3Up, imageUp: beigeRefresh }
}
Then create a button:
ImageButton btnRefresh = new ImageButton(skin, "default");
stage.addActor(btnRefresh);
In the end you'll see a button without an image at center, which specified in the default style.
Version of libGDX and/or relevant dependencies
1.12.1
Stacktrace
//Please provide the stacktrace if applicable
Please select the affected platforms
- [*] Android
- iOS
- HTML/GWT
- [*] Windows
- Linux
- macOS
I use ImageButton all the time in the way you describe. Can you provide a skin and simple project that demonstrates the issue?
@raeleus I can't because it's a commerсial project. But this issue is easy to recreate in empty libgdx project. If you want, I will recreate it.
Yes, please do.
It is caused by hight differencies in button background (down) and button foreground (imageDown) size.
I can't find where it is, but it is probably in Group#draw(...)
or Table#draw(...)
. Margin is the same for a big and for a small button, for the small one center image is <0