为什么我的视图背景会在动画期间发生变化?

时间:2011-08-19 00:26:09

标签: android background-color android-animation android-3.0-honeycomb

简单的动画;我只想要一些东西滑到左边。

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="0"
               android:toXDelta="-100%"
               android:duration="1000"/>
</set>

我有一个ExpandableListView:

<ExpandableListView android:id="@id/android:list"
                    android:background="@android:color/transparent"
                    ... />

我申请了这个:

ExpandableListView list = getExpandableListView();
Animation anim = AnimationUtils.loadAnimation(TvEventListActivity.this, R.anim.left);
list.startAnimation(anim);

当我开始动画时,列表背景应该是透明的,在动画持续时间内会变为纯灰色背景。然后恢复正确。

为什么会这样?我该如何预防?

1 个答案:

答案 0 :(得分:1)

如果使用背景Drawable,请务必将android:cacheColorHint设置为透明,如果使用纯色,请务必将背景颜色设置为相同。