Android grow LinearLayout using animation

后端 未结 4 695
灰色年华
灰色年华 2021-02-05 11:31

I am trying to use animation to make a layout appear on screen. The idea is that layout will start with height of 0 and grow to 100%.

I have real troubles with this and

4条回答
  •  太阳男子
    2021-02-05 12:03

    Designing a growing linearlayout in android:

    For the ones who are using Mono android of Xamarin:

    make a folder anim under resources.

    then add animation.xml in anim folder(grow_anim1)

    in the activity class use this way:

    (in my case I am using 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;
    using Android.Views.Animations;
    namespace BehnoudAndroidApp {
        public class StartPageFragment : Fragment{
            public override View OnCreateView(LayoutInflater p0, ViewGroup p1, Bundle p2){
                var rootView = p0.Inflate(Resource.Layout.StartPageLayout, p1, false);
    
                LinearLayout menu1 = rootView.FindViewById(Resource.Id.linearlayout1);
    
                Animation animation1 = AnimationUtils.LoadAnimation(this.Activity, Resource.Animation.grow_anim1);
    
                animation1.Duration = 5000;
    
                menu1.Click += delegate { menu1.StartAnimation(animation1); };
    
                return rootView;
            }
        }
    }
    

提交回复
热议问题