Android背景出现绑带
问题描述:
我想使用GradientDrawable设置背景。一切工作正常,但背景显示与重要的条带。我试图启用抖动,但它没有变得更好。下面是一个屏幕截图:Android背景出现绑带
从编码的角度看,我已经做到了这一点:
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>
有什么办法让这看起来更好吗?谢谢!
答
好吧,这里有一个关于这个问题的链接,希望它可以帮助你的问题: http://www.curious-creature.org/2010/12/08/bitmap-quality-banding-and-dithering/ 它给了一个很好的解释。
也许这个职位将帮助:http://stackoverflow.com/questions/4769885/androiddither-true-does-not-dither-whats-wrong/5581537 – 2013-05-09 23:49:39
谢谢。我已经看到了这一点,并实施了一些建议。但是,这个解决方案建议使用Photoshop创建一个我无法访问的png文件。在这个确切的问题上还有一些其他的SO帖子。我已经经历了所有这些,但仍然有同样的问题。 – Alex 2013-05-10 00:23:39
我也不使用Photoshop,但是http://gimp.org是免费的。 – 2013-05-10 00:41:42