2013-05-09 7 views
0

GradientDrawable을 사용하여 배경을 설정하려고합니다. 배경이 뚜렷한 줄무늬로 나타나는 것을 제외하면 모든 것이 잘 작동합니다. 나는 디더링을 가능하게하려고 노력했지만 더 좋아지지는 않습니다. 여기에 스크린 샷 :Android 배경이 줄무늬로 표시됩니다.

enter image description here

코딩 관점에서, 나는이 짓을했는지 :

public class MainActivity extends Activity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     /* Deal with gradient banding */ 
     getWindow().setFormat(PixelFormat.RGBA_8888); 

     setContentView(R.layout.activity_main);  
    } 

    /* Another attempt to deal with the banding */ 
    @Override 
    public void onAttachedToWindow() { 
     super.onAttachedToWindow(); 
     Window window = getWindow(); 
     window.setFormat(PixelFormat.RGBA_8888); 
    } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     // Inflate the menu; this adds items to the action bar if it is present. 
     getMenuInflater().inflate(R.menu.main, menu); 
     return true; 
    } 

} 

그리고를 마지막으로 XML 파일 :

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:background="@drawable/background" 
    tools:context=".MainActivity" > 
</RelativeLayout> 

drawable/background.xml

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <gradient 
     android:angle="90" 
     android:startColor="#999" 
     android:endColor="#fff" 
     android:type="linear" 
      android:dither="true" 
    /> 
</shape> 

이 모양을 더 좋게 만들 수있는 방법이 있습니까? 고맙습니다!

+0

이 게시물이 도움이 될 수 있습니다. http://stackoverflow.com/questions/4769885/androiddither-true-does-not-dither-whats-wrong/5581537 –

+0

감사합니다. 나는 이것을 보았고 그것에 대한 몇 가지 제안을 이행했다. 그러나이 솔루션은 Photoshop을 사용하여 액세스 권한이없는 png 파일을 만드는 것이 좋습니다. 이 정확한 문제에 대한 몇 가지 다른 게시물이 있습니다. 나는 그들 모두를 겪어 왔지만 여전히 같은 문제가 있습니다. – Alex

+0

Photoshop을 사용하지 않지만 http://gimp.org는 무료입니다. –

답변

관련 문제