作者:香水百合-2012 | 来源:互联网 | 2023-01-29 15:40
使用位图可能会帮助您。像这样使用:
Bitmap nameYourBitmap;
Bitmap resized = Bitmap.createScaledBitmap(nameYourBitmap, newWidth, newHeight, true);
您也可以这样:
resized = Bitmap.createScaledBitmap(nameYourBitmap,(int)(nameYourBitmap.getWidth()*0.8), (int)(nameYourBitmap.getHeight()*0.8), true);
请参考:如何在Android中调整图片大小?
对于XML,比例属性是为ScaleDrawables定义的,它们可以缩放另一个可绘制对象。请访问此开发者网站:https : //developer.android.com/guide/topics/resources/drawable-resource.html#Scale
1> Animesh Patr..:
使用位图可能会帮助您。像这样使用:
Bitmap nameYourBitmap;
Bitmap resized = Bitmap.createScaledBitmap(nameYourBitmap, newWidth, newHeight, true);
您也可以这样:
resized = Bitmap.createScaledBitmap(nameYourBitmap,(int)(nameYourBitmap.getWidth()*0.8), (int)(nameYourBitmap.getHeight()*0.8), true);
请参考:如何在Android中调整图片大小?
对于XML,比例属性是为ScaleDrawables定义的,它们可以缩放另一个可绘制对象。请访问此开发者网站:https : //developer.android.com/guide/topics/resources/drawable-resource.html#Scale