2011-05-04 2 views
3

입니다.왜 내가 뭐하는 거지 내 수입 PNG 등 품질이 낮은

에뮬레이터에서 볼 때 이미지의 품질이 매우 낮습니다. 그것의 PNG 320x480 (96dpi와 낮은, 중간 및 높은 폴더에서 동일). 내 안드로이드 앱을 제작할 때 티타늄을 사용할 때 괜찮아 보였습니다. 나는 지금 이클립스와 자바를 사용하고 있으며 나빠 보인다.

답변

10

고해상도 이미지를 액티비티 배경으로 설정하는 동안이 문제가 발생했으며 액티비티의 onCreate() 메서드에서 다음 자바 코드를 사용하여이 문제를 해결할 수있었습니다.

 BitmapFactory.Options myOptions = new BitmapFactory.Options(); 
     myOptions.inDither = true; 
     myOptions.inScaled = false; 
     myOptions.inPreferredConfig = Bitmap.Config.ARGB_8888; 
     myOptions.inDither = false; 
     myOptions.inPurgeable = true; 
     Bitmap preparedBitmap = BitmapFactory.decodeResource(yourAppName.getSharedApplication().getResources(), 
       R.drawable.yourImage, myOptions); 
     Drawable background = new BitmapDrawable(preparedBitmap); 
     ((LinearLayout) findViewById(R.id.yourLayoutId)) 
      .setBackgroundDrawable(background); 

또한이 코드를 사용하는 경우 레이아웃 xml에서 배경을 설정하지 마십시오. 문제가 해결되지 않는 경우 것은 희망이 도움이 AndroidManifest.xml에

<supports-screens android:largeScreens="true" 
    android:normalScreens="true" android:smallScreens="true" 
    android:anyDensity="true" /> 

응용 프로그램 태그 외부에 다음 줄을 설정해보십시오!

8

저를 위해 "res/drawable_hdpi"폴더로 옮겨보십시오.

+0

이미 세 폴더에 모두 동일한 이미지가 있습니다. 어쩌면 내가 테스트하는 에뮬레이터가 낮은 dpi 또는 무언가로 설정되어 있습니다 – Ronnie

+0

SDK는 모든 이미지를 최적화하므로 다른 옵션이 있다고 생각합니다. -/res/raw 폴더 (빌드 프로세스 중에 변경되지 않은 상태로 유지 한 파일)에 넣고로드하십시오 수동으로 [Resources.openRawResource()] (http://developer.android.com/reference/android/content/res/Resources.html#openRawResource (int))를 사용하십시오. – Grishka

+0

위와 같은 방법으로 XML에서 해당 호출을 수행 할 수 없습니다. 어떻게하면 Java를 사용하여 응용 프로그램의 배경을 설정하겠습니까? – Ronnie

관련 문제