如何增加或减少ImageView的大小?

时间:2012-07-26 20:54:49

标签: android

我想知道如何放大已在ImageView中的图像。

我有这个:

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);

但它什么也没做,图像保持不变。

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

你是否使视图无效?在您的活动中使用invalidate()或postInvalidate()?