2014-11-06 47 views
0

我想动画一个TextView从顶部向下滑动到中心,然后反弹并保持停滞状态。我已经放了一个代码,它完美地弹跳,但是我遇到的问题是它没有显示滑动效果。该文本仅在动画持续时间结束后出现,然后反弹。在XML代码如下提出:如何在android中完美地添加幻灯片并反弹动画?

<set xmlns:android="http://schemas.android.com/apk/res/android" 
android:shareInterpolator="false" 
android:fillAfter="false"> 

<translate 
    android:duration="1000" 
    android:fillAfter="true" 
    android:fromYDelta="-100%p" 
    android:toYDelta="0%p"/> 

<scale 
    android:interpolator="@android:anim/bounce_interpolator" 
    android:duration="500" 
    android:fillAfter="true" 
    android:fromXScale="1.0" 
    android:fromYScale="0.0" 
    android:startOffset="1000" 
    android:toXScale="1.0" 
    android:toYScale="1.0"/> 

如果有人能帮助我度过这个将是巨大的。

回答

0

我认为你正在使用

android:toYDelta="0%p" 

这是造成你的问题。你使用过这个可能是因为你已经将TextView放在了屏幕上。所以,在我看来,你不应该集中你的TextView在布局和做这样的事情在你的XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
> 
    <TextView 
    android:id="@+id/tv_text" 
    android:layout_centerHorizontal="true" 
    android:text="23" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    /> 

,然后改变你的一套动画这个

<set xmlns:android="http://schemas.android.com/apk/res/android" 
android:fillAfter="true" 
android:shareInterpolator="false" > 

<translate 
    android:duration="1000" 
    android:fromYDelta="-100%p" 
    android:toYDelta="50%p" 
    /> 

<scale 
    android:duration="500" 
    android:fromXScale="1.0" 
    android:fromYScale="0.0" 
    android:interpolator="@android:anim/bounce_interpolator" 
    android:startOffset="1000" 
    android:toXScale="1.0" 
    android:toYScale="1.0" /> 

</set>