0

简单的动画;我只想让东西滑向左边。为什么我的视图在动画过程中会发生变化?

<?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

什么是你的ExpandableListView的'android:cacheColorHint'值? –

+0

我还没有设置它。将它设置为'@android:color/transparent'解决了这个问题。输入该答案作为答案,然后我将选中它。 :) –

+0

也'''标签是不必要的。我删除了它们,只是让''成为根。 –

回答

1

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

相关问题