从片段到活动时的动画

时间:2016-11-17 14:21:17

标签: android android-fragments xamarin xamarin.android

我在text view中有fragment当我点击文字视图时,会调用一个活动,这会将我带到一个我怀疑的新布局。是否可以在从片段布局到活动布局的同时进行动画制作。

这是我的片段

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;`
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Util;
using Android.Views;
using Android.Widget;



namespace TabbedApp
{
    public class IconTextCallFragment : Android.Support.V4.App.Fragment
    {
        public override void OnCreate (Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);


        }

        public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {

            // Use this to return your custom view for this Fragment 
            View view =inflater.Inflate(Resource.Layout.IconTxtCallLayout, container, false);
            var textView = view.FindViewById<TextView>(Resource.Id.clickable_text_view);
            textView.Click += StartNewActivity;

            return view;
        }
        void StartNewActivity(object sender, EventArgs e)
        {
            Intent intent = new Intent(this.Activity, typeof(Activity1));
            this.StartActivity(intent);
            var trans = this.FragmentManager.BeginTransaction();

            trans.SetCustomAnimations(Resource.Animation.BounceTop, Resource.Animation.Slide_out, Resource.Animation.BounceTop, Resource.Animation.Slide_out);

            trans.AddToBackStack(null);
            trans.Commit();


        }

    }
}

活动:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;

namespace TabbedApp
{
    [Activity(Label = "Activity1")]
    public class Activity1 : Activity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.layout1);

        }
    }
}

0 个答案:

没有答案