我正在尝试将线性渐变应用于我的ListView。这是我的可绘制xml的内容:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#3A3C39"
android:endColor="#181818"
android:angle="270"
/>
<corners android:radius="0dp" />
</shape>
因此,我将其应用于我的ListView:
android:background="@drawable/shape_background_grey"
它可以工作,但它在模拟器和真实设备上看起来非常“带状”。
有没有办法减少这种“行为”?
发布于 2010-05-29 03:50:48
就像Romain Guy建议的那样:
listView.getBackground().setDither(true);
解决了我的问题
如果这还不够,特别是对于AMOLED和/或hdpi设备,请尝试执行以下操作:
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);
}
发布于 2010-05-29 01:36:05
您可以简单地在可绘制对象上启用抖动。
发布于 2011-06-11 02:03:14
把这个放到你的活动中:
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);
}
https://stackoverflow.com/questions/2928101
复制相似问题