读者可以引用这个问题:android:dither="true" does not dither, what's wrong?
我也有色带......解决方案是为我的带有渐变的 png 图像创建一个别名(在 xml 中)并将抖动设置为“true”。 在我的 list 文件中指定 SDK 版本之前一直有效 <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8" />
...
使用 Android 1.6(API 级别 4)和皮肤 WVGA800 的模拟器上再次出现色带
有人能解释一下为什么吗!?
项目文件:https://rapidshare.com/files/3429393846/Dithering.zip
--
我的布局和目标到它的背景(抖动的别名):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/d_gradient_grey_dither">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
背景(d_gradient_grey_dither.xml):
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/d_gradient_grey"
android:antialias="true"
android:dither="true"/>
list 文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Main"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8" />
</manifest>
在这里查看结果:
如果有帮助,项目文件:
https://docs.google.com/leaf?id=0B6Y0F7DEUPbPZTM5MDU0YzAtNjJiYi00NTU0LTlmNTAtMWJiZTJhNjBhYjA3&hl=fr
或(压缩)
最佳答案
这就是我使用的,我已经通过 API 11 使用了。
/** -- Eliminates color banding -- **/
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);
}
关于android - 在 list 中定义 sdk-version 后色带解决方案被杀死,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6028753/