views:

238

answers:

1

I have a custom class that extends ImageView that I'm programatically putting on to a RelativeLayout. I want each one of these images to be a specific width and height. I've tried setting the width/height in code with LayoutParams and with setMaxWidth/setMaxHeight...neither seem to be working.

Here is the code from the constructor of the class:

LayoutParams p = new LayoutParams(50,67);       
        this.setLayoutParams(p);
        this.setImageResource(WhichImage(wi));
        this.setMaxWidth(50);
        this.setMaxHeight(67);

I've moved the call to setImageResource() above and below everything there and it still defaults to the true image size in my drawables...

A: 

You probably need to tell the ImageView how to scale. Try using ImageView#setScaleType.

Qberticus