2013-07-19 63 views
2

我的问题说明

在这张截图的ListView有两个ListView秒。动画细胞出的Android

enter image description here

我想达到的目标是,当我触摸紫色ListView下,接触的细胞将向上移动,并在蓝色ListView的底部的位置停止。

例如,如果我触摸了“决定心脏移植”,那么它们将是一个动画,显示该细胞向上移动,然后停止在“肝移植”位置。

我曾尝试

我在紫ListView

@Override 
    public void onListItemClick(ListView l, View v, int position, long id) { 


     // Setup the animation view 

     Log.d("onListItemClick", "Position: " + viewForAnim.getX() + ", " + viewForAnim.getY()); 

     // Move up the selected view 
     Animation animation = null; 

     animation = new TranslateAnimation(0, 0, 0, -v.getY()-l.getY()); 
     animation.setDuration(700); 
     v.startAnimation(animation); 
} 

试过,但,这似乎将在ListView的绑定选定单元格移动,不能移动出来。

认为动画紫ListView的电池可能会由蓝色ListView的覆盖,我甚至尝试用

l.bringToFront(); 

但是,这种没有任何工作改变ListView控件的Z顺序。

,我也想尽了办法显示,该SO后

Android -- How to position View off-screen?

它可能会为动画视图工作得很好,但是这并没有对我的情况下工作。

然后我试着设置android:clipChildren,那对于需要将列表视图移出来的动画不起作用。

所以你们可以指点我一个正确的方法如何实现这种动画效果?

回答

1

尝试使用relative_to_parent在翻译动画

+0

看看API演示源代码..你会得到这样的例子.. – shreyas

+0

THX,我只是用'动画=新TranslateAnimation(Animation.RELATIVE_TO_SELF尝试,0,Animation.RELATIVE_TO_SELF,0,Animation.RELATIVE_TO_SELF,0,Animation.RELATIVE_TO_PARENT,-100);'即使运动设置为-100,对我来说动画就是被触摸的单元格消失,根本没有动画。你能指出我应该看看哪个例子吗? – dumbfingers

+0

在com.example.android.apis.view包中查看layoutanimation类... – shreyas