我所希望的是:设置一个ImageView里面的图片宽度一定,而高度按原长宽比例放大或缩小。
我这样设置的:
<ImageView android:layout_width="250dip"
android:scaleType="fitCenter"
android:layout_marginRight="10dip" android:layout_marginLeft="10dip"
android:layout_marginBottom="15dip" android:layout_height="wrap_content"
android:id="@+id/article_img" />后来发现,确实宽度是够了,图片也确实是按比例的放大没有失真但是我发现 height并没有 按比例放大了啊~ 而是 只有一部分~ 就好像这个图在在高度上 截走了一样怎么样 调到这种效果呢??
我这样设置的:
<ImageView android:layout_width="250dip"
android:scaleType="fitCenter"
android:layout_marginRight="10dip" android:layout_marginLeft="10dip"
android:layout_marginBottom="15dip" android:layout_height="wrap_content"
android:id="@+id/article_img" />后来发现,确实宽度是够了,图片也确实是按比例的放大没有失真但是我发现 height并没有 按比例放大了啊~ 而是 只有一部分~ 就好像这个图在在高度上 截走了一样怎么样 调到这种效果呢??
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
Bitmap resizeBmp = Bitmap.createBitmap(bmp, 0, 0, bmpWidth, bmpHeight, matrix, true);
float scaleWidth = OularDataManager.deviceWidth - 20;
// float scaleHeight=(int)((OularDataManager.deviceWidth-20)*drawScale);
float scale = scaleWidth / temp.getWidth();
Matrix matrix = new Matrix();
matrix.postScale(scale, scale);
// matrix.postScale(0.5f, 0.5f);
Bitmap temp2 = Bitmap.createBitmap(temp, 0, 0, temp.getWidth(),
temp.getHeight(), matrix, true);
return temp2;
}
但是问题是 ,这样即时的做,有时让我的程序直接崩溃啊~,郁闷,有没有用imageview设定的方法啊?