我一直在试图让android抖动一个活动的背景图像 - 迄今没有成功。我不知道什么是错的。android:dither =“true”不抖动,怎么了?
这是我做过什么:
我的活动布局的根元素是一个LinearLayout中:
<LinearLayout android:id="@+id/AbsoluteLayout01"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:gravity="center_horizontal"
android:background="@drawable/background_dither">
,我添加@绘制/ background_dither作为背景图像。 我把一个XML文件“background_dither.xml”的绘制,华电国际,内容如下:
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/backimg"
android:src="@drawable/background"
android:dither="true"
android:antialias="true" />
它引用绘制,华电国际的实际图像background.png。包含大色彩渐变的图像确实显示出来,但颜色带很浓。从我从SDK中学到的东西,通过使用/ above代理映像定义和指定android:dither =“true”,可以缓解这个问题。但是,这完全没有影响。
我错过了什么让抖动工作?
EDIT
:上传的sources here
EDIT2
:后无的建议的方法有助于摆脱色带,阅读this blog post from Romain Guy后,我有了主意,检查我的PNG背景是否具有alpha通道。它没有。添加一个之后,android实际上似乎使用了RGB8888,就像在帖子中所说的那样,绑定消失了(也为2.2)。仍然想知道为什么其他方法不起作用。
EDIT3
:必须确保PNG不仅具有alpha通道,而且还有至少一个具有alpha值!= FF的像素,否则android构建工具将再次将该位图剥离为索引没有Alpha通道的调色板。
谢谢。试了两种选择。他们都没有改变渲染,所以我想它仍然不起作用。 :-( – machtnix 2011-01-22 21:17:49