启动画面动画

时间:2015-09-19 07:31:38

标签: c# android xamarin

我为Android编写应用程序并希望制作动画启动画面

我像这样做了图像启动画面

Styles.xml:

 <resources>
  <style name="Theme.Splash" parent="android:Theme">
    <item name="android:windowBackground">@drawable/splash</item>
    <item name="android:windowNoTitle">true</item>
  </style>
</resources>

和SplashActivity:

[Activity(Theme = "@style/Theme.Splash", MainLauncher = true, NoHistory = true)]
public class SplashActivity : Activity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        Thread.Sleep(10000); 
        StartActivity(typeof(Activity1));
    }
}

但我有4个像素,我想制作动画闪屏。我怎么能这样做?

2 个答案:

答案 0 :(得分:0)

使用动画列表 - 在您的drawable文件夹中创建xml,如下所示:

ImageView your_imageView = (ImageView) findViewById(R.id.rocket_image);
your_imageView.setBackgroundResource(R.drawable.your_animation_list);
AnimationDrawable your_animation = (AnimationDrawable) your_imageView.getBackground();

your_animation.start(); // Start the animation

然后像这样开始动画:

{{1}}

答案 1 :(得分:0)

您可以使用FadeImageView类https://blog.xamarin.com/android-tricks-fadeimageview/从一个图像淡入淡出到另一个图像

包含FadeImageView作为教程,并使用以下内容设置动画:

using Android.Views.Animations;

AlphaAnimation fadeIn;
AlphaAnimation fadeOut;

fadeIn = new AlphaAnimation (0, 1) {Duration = 500};
fadeOut = new AlphaAnimation (1, 0) {Duration = 500};

然后设置动画结束时要发生的事情,如调用更改图像的方法

EventHandler<Animation.AnimationEndEventArgs> callback = (s, e) => {
    StartAnimation (fadeOut);
    ChangePic ();

};
fadeIn.AnimationEnd += callback;

fadeimageview.SetImageBitmap(bitmap);
fadeimageview.StartAnimation (fadeIn);

ChangePic简单:

private void ChangePic(){
   if (bitmapList.Count >= 1)
   {
      fadeimageview.SetImageBitmap(bitmapList[bitmapList.Count - 1]);
      bitmapList.RemoveAt[bitmapList.Count - 1];
      fadeimageview.StartAnimation (fadeIn);
   }
}