错误是 java.lang.OutOfMemoryError

Error is java.lang.OutOfMemoryError

        File imgFile = new File(path);

        if (imgFile.exists()) {
            BitmapFactory.Options options=new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            options.inSampleSize = 2;
            options.inJustDecodeBounds = false;
            options.inTempStorage = new byte[16 * 1024];

        Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
        //Drawable d = new BitmapDrawable(getResources(), myBitmap);
        float scale = context.getResources().getDisplayMetrics().density;
        holder.userprofile.setImageBitmap(myBitmap);
        holder.userprofile.setLayoutParams(new LinearLayout.LayoutParams((int) (350 * scale), (int) (300 * scale)));

        holder.userprofile.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (isImageFitToScreen) {
                    Toast.makeText(context, "NORMAL SIZE!", Toast.LENGTH_LONG).show();


                    float scale = context.getResources().getDisplayMetrics().density;
                    holder.userprofile.setLayoutParams(new LinearLayout.LayoutParams((int) (350 * scale), (int) (300 * scale)));
                    holder.userprofile.setAdjustViewBounds(true);


                    isImageFitToScreen = false;
                } else {
                    Toast.makeText(context, "FULLSCREEN!", Toast.LENGTH_LONG).show();
                    float scaleHeigth = context.getResources().getDisplayMetrics().heightPixels;
                    float scaleWidth = context.getResources().getDisplayMetrics().widthPixels;
                    holder.userprofile.setLayoutParams(new LinearLayout.LayoutParams((int) scaleWidth, (int) scaleHeigth));
                    holder.userprofile.setScaleType(ImageView.ScaleType.FIT_XY);


                    isImageFitToScreen = true;
                }

            }
        });

问题是应用程序由于 memoryError 运行速度太慢错误是当单击图像上的按钮时它将以全屏图像显示,再次单击图像将再次显示为原始图像。 这是错误:

java.lang.OutOfMemoryError: Failed to allocate a 63701004 byte allocation with 16777120 free bytes and 49MB until OOM

提前致谢

像这样使用 optionsdecodeFile 方法:

Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath(), options);