ImageView titleImge = (ImageView) buyPopWindow.getContentView()
.findViewById(R.id.pop_title_img);
titleImge.setImageBitmap(bitmap);
Drawable drawable = titleImge.getDrawable();
int height = (int) (drawable.getIntrinsicHeight() * 1.0
/ drawable.getIntrinsicWidth() * width);
titleImge.setLayoutParams(new LinearLayout.LayoutParams(width,
height));
动态设置ImageView的大小,保持图片比例,LayoutParams()根据父容器的类型,设置为
LinearLayout.LayoutParams或RelatvieLayout.LayoutParams,ViewGroup.LayoutParams等不同类型,否则会发生类型转换错误。