我正在尝试在Xamarin.Android项目中为我的启动画面上的ImageView
设置动画。图像相应地淡入/翻译,位于屏幕中间一秒钟,然后尝试翻译出来。问题在于,当从屏幕顶部翻译时动画卡住了一半时间。
布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/logoImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginBottom="40dp"
android:layout_marginTop="70dp"
android:background="@null"
android:src="@drawable/logo_light"
android:scaleType="centerInside"
android:visibility="invisible" />
</RelativeLayout>
在SplashActivity中:
public override void OnWindowFocusChanged(bool hasFocus)
{
if (hasFocus)
StartAnimations();
}
private void StartAnimations()
{
imageView = FindViewById<ImageView>(MySolution.Droid.Resource.Id.logoImageView);
imageView.Visibility = 0;
// Fade In
var fadeIn = new AlphaAnimation(0, 1);
fadeIn.Duration = 500;
fadeIn.Interpolator = new AccelerateInterpolator();
var transLateIn = new TranslateAnimation(0, 0, -200, 0);
transLateIn.Duration = 750;
transLateIn.Interpolator = new LinearInterpolator();
var delay = new AlphaAnimation(1, 1);
delay.StartOffset = 750;
delay.Duration = 1000;
var transLateOut = new TranslateAnimation(0, 0, 0, -5000);
transLateOut.StartOffset = 1750;
transLateOut.Duration = 750;
transLateOut.Interpolator = new LinearInterpolator();
transLateOut.FillAfter = false;
var fadeInSet = new AnimationSet(false);
fadeInSet.AddAnimation(fadeIn);
fadeInSet.AddAnimation(transLateIn);
fadeInSet.AddAnimation(delay);
fadeInSet.AddAnimation(transLateOut);
imageView.StartAnimation(fadeInSet);
}
有人能说清楚为什么会这样吗?