簡體   English   中英

在 xamarin forms 的初始屏幕中設置動畫或從底部到頂部的過渡?

[英]Animate or do a transition from bottom to top in splash screen in xamarin forms?

我試圖在初始屏幕的底部有一個帶有徽標的背景圖像。 在 ios 和 Android(xamarin 形式)中加載初始屏幕后,應該會發生從底部到中心的轉換。 請分享你的想法?

如果您想要 Animation 啟動畫面,請按照以下步驟操作。 我在 Android 中做了一個樣本。

首先,請創建 SplashScreen.axml。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
 <ImageView
     android:layout_width="wrap_content"
     android:layout_height="wrap_content" 
    android:id="@+id/imageView1" 
    android:src="@drawable/splash_logo" 
    android:gravity="bottom|center_horizontal"/>
</LinearLayout>

其次,在Resource文件夾下創建Anim文件夾,創建bottomtotop.xml animation關於翻譯。

<?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="http://schemas.android.com/apk/res/android"
     android:interpolator="@android:anim/linear_interpolator">

 <translate 
         android:fromYDelta="100%p"
         android:toYDelta="0"
         android:duration="600"/>

 </set>

第三,使用 animation 創建新的活動名稱 SplashScreenDemo.cs。 設置 MainLauncher = true。

 [Activity(Label = "SplashScreenDemo", MainLauncher = true)]
public class SplashScreenDemo : Activity
{
    ImageView imageView;
    Animation view_animation;
    TextView textview;
    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);

        SetContentView(Resource.Layout.SplashScreen);
        imageView = FindViewById<ImageView>(Resource.Id.imageView1);
        view_animation = AnimationUtils.LoadAnimation(this, Resource.Animation.bottomtotop);
        imageView.StartAnimation(view_animation);
        view_animation.AnimationEnd += Rotate_AnimationEnd;
        // Create your application here
    }

    private void Rotate_AnimationEnd(object sender, Animation.AnimationEndEventArgs e)
    {
       // Finish();
        Intent intent;
        intent = new Intent(Application.Context, typeof(MainActivity));
        StartActivity(intent);
       
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM