我想下载一个图像(大小不明,但始终大致为正方形)并显示它,以便它在任何屏幕尺寸上都水平填充屏幕,并垂直拉伸以保持图像的纵横比。这是我的(无效)代码。它水平拉伸图像,但不垂直拉伸图像,因此将其压扁...
ImageView mainImageView = new ImageView(context);
mainImageView.setImageBitmap(mainImage); //downloaded from server
mainImageView.setScaleType(ScaleType.FIT_XY);
//mainImageView.setAdjustViewBounds(true);
//with this line enabled, just scales image down
addView(mainImageView,new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
BIG阳
海绵宝宝撒