动画 TextView 滑出屏幕
Animate a TextView to slide off the screen
我正在使用以下代码为 TextView 设置动画:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="1000"
android:toYDelta="100%"
android:fromYDelta="0%" />
</set>
并这样做:
textView.startAnimation(slideOutAnim);
但此代码仅使 TextView 动画显示大约 1/4 的屏幕长度。我应该将 toYDelta 设置为什么以确保 TextView 在屏幕之外?我知道我可以将它设置为一个非常高的数字,但是否有更多 efficient/effective 方法来完成此操作?谢谢
将您的动画更改为:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="1000"
android:toYDelta="100%p"<!--relative to parent-->
android:fromYDelta="0%" />
</set>
请注意,如果它的父级具有全屏高度,则此工作有效,实际上它会动画到其父级高度的 100%
我正在使用以下代码为 TextView 设置动画:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="1000"
android:toYDelta="100%"
android:fromYDelta="0%" />
</set>
并这样做:
textView.startAnimation(slideOutAnim);
但此代码仅使 TextView 动画显示大约 1/4 的屏幕长度。我应该将 toYDelta 设置为什么以确保 TextView 在屏幕之外?我知道我可以将它设置为一个非常高的数字,但是否有更多 efficient/effective 方法来完成此操作?谢谢
将您的动画更改为:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="1000"
android:toYDelta="100%p"<!--relative to parent-->
android:fromYDelta="0%" />
</set>
请注意,如果它的父级具有全屏高度,则此工作有效,实际上它会动画到其父级高度的 100%