Dracknes
Dracknes

Reputation: 79

How I can increase or decrease the size of an ImageView?

I would like to know how to enlarge an image that is already in the ImageView.

I have this:

m_imageView.setImageBitmap(imagen); 
int newHeight = getWindowManager().getDefaultDisplay().getHeight() / 2;
int orgWidth = m_imageView.getDrawable().getIntrinsicWidth();
int orgHeight = m_imageView.getDrawable().getIntrinsicWidth();
int newWidth = (int) Math.floor((orgWidth * newHeight) / orgHeight);
//Use RelativeLayout.LayoutParams if your parent is a RelativeLayout
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                newWidth, newHeight);
m_imageView.setLayoutParams(params);
//m_imageView.setScaleType(ImageView.ScaleType.FIT_START);

But it does nothing, the image remains the same.

Thank you for your help.

Upvotes: 0

Views: 316

Answers (1)

jcfrei
jcfrei

Reputation: 1809

did you invalidate the view? with invalidate() or postInvalidate() on your activity?

Upvotes: 1

Related Questions