0
 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와입니다. 오류가

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

이 같은 decodeFile 방법을 사용 options 사전

+0

어디 OOM이 발생 않았다 이 오류가? myBitmap 할당 또는 onClick 메서드에서? – nshmura

+0

myBitmap 할당 @nshmura –

답변

0

에 감사 :

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

고맙습니다 ... @nshmura –