您可以在为它们创建位图之前缩小图像。
public Bitmap decodeSampledBitmapFromPath(String path) 
{
    // First decode with inJustDecodeBounds=true to check dimensions
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(path, options);
    // Calculate inSampleSize
    options.inSampleSize = calculateInSampleSize(options, requiredWidth, requiredHeight);
    // Decode bitmap with inSampleSize set
    options.inJustDecodeBounds = false;
    Bitmap newBmap = BitmapFactory.decodeFile(path, options);
    return newBmap;
}
public int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) 
{
    int inSampleSize = 1;
    if (imageHeight > reqHeight || imageWidth > reqWidth) 
    {
        if (imageWidth > imageHeight) 
        {
            inSampleSize = Math.round((float)imageHeight / (float)reqHeight);
        } 
        else 
        {
            inSampleSize = Math.round((float)imageWidth / (float)reqWidth);
        }
    }
    return inSampleSize;
}
如果图像比加载它们的视图大很多,那么这种缩小确实有助于更快地创建位图。此外,与直接创建位图相比,缩放Bitmap占用的内存要少得多。
inJustDecodeBounds在BitmapFactory.Options设置true为时,您可以在为其创建之前获取高度和宽度Bitmap。因此,您可以检查图像是否大于要求。如果是,则将它们缩放到所需的高度和宽度,然后创建其Bitmap.
希望这可以帮助!