2

We're running into a problem trying to use GWT sprites for different-sized buttons, using the same background image, like so:

@Source("background.png")
@ImageOptions(width=200,height=50)  
ImageResource wideButton();

@Source("background.png")
@ImageOptions(width=100,height=50)  
ImageResource narrowButton();

In the css we use the image resource like so:

@sprite .wideButton {
gwt-image: "wideButton"; }

@sprite .wideButton {
gwt-image: "narrowButton"; }

This produces DIV elements with the proper dimension, but it does not display the image properly when these dimensions are smaller than the image's original width and height: the picture is cropped to fit, rather than scaled. Setting the width and height in the css does not solve the display problem.

@sprite .wideButton {
gwt-image: "narrowButton"; 
    width: 100px;
    height: 50px;
}

Is there a way to make this work, or were sprites simply not designed to be used in this way? Thanks in advance.

1
  • Having exactly the same problem at the moment. Strange as I'm sure the docs say it will be scaled and I've seen others talk about scaling images this way. Did you find out what was wrong in the end? Commented Oct 27, 2013 at 12:55

0

Browse other questions tagged or ask your own question.