예제 #1
0
        public static Bitmap ToBitmap(this AView view)
        {
            var layout = new FrameLayout(view.Context);

            layout.LayoutParameters = new FrameLayout.LayoutParams(500, 500);
            view.LayoutParameters   = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WrapContent, FrameLayout.LayoutParams.WrapContent)
            {
                Gravity = GravityFlags.Center
            };

            layout.AddView(view);
            layout.Measure(500, 500);
            layout.Layout(0, 0, 500, 500);

            var act      = view.Context.GetActivity();
            var rootView = act.FindViewById <FrameLayout>(Android.Resource.Id.Content);

            rootView.AddView(layout);

            var    bitmap = Bitmap.CreateBitmap(view.Width, view.Height, Bitmap.Config.Argb8888);
            Canvas canvas = new Canvas(bitmap);

            view.Layout(0, 0, view.Width, view.Height);
            view.Draw(canvas);

            rootView.RemoveView(layout);

            return(bitmap);
        }
예제 #2
0
        public static async Task <T> AttachAndRun <T>(this AView view, Func <T> action)
        {
            var layout = new FrameLayout(view.Context);

            layout.LayoutParameters = new FrameLayout.LayoutParams(500, 500);
            view.LayoutParameters   = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WrapContent, FrameLayout.LayoutParams.WrapContent)
            {
                Gravity = GravityFlags.Center
            };

            var act      = view.Context.GetActivity();
            var rootView = act.FindViewById <FrameLayout>(Android.Resource.Id.Content);

            rootView.AddView(layout);

            layout.AddView(view);
            layout.Measure(500, 500);
            layout.Layout(0, 0, 500, 500);

            await Task.Delay(100);

            try
            {
                var result = action();
                return(result);
            }
            finally
            {
                rootView.RemoveView(layout);
                layout.RemoveView(view);
            }
        }
예제 #3
0
        public void AcKapat()
        {
            int sayac1 = ListeHaznesi.Height;

            if (durum == false)
            {
                ListeHaznesi.Visibility = ViewStates.Visible;
                int widthSpec  = View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);
                int heightSpec = View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);
                ListeHaznesi.Measure(widthSpec, heightSpec);

                ValueAnimator mAnimator = slideAnimator(0, ListeHaznesi.MeasuredHeight);
                mAnimator.Start();
                durum = true;
            }
            else if (durum == true)
            {
                int finalHeight = ListeHaznesi.Height;

                ValueAnimator mAnimator = slideAnimator(finalHeight, 0);
                mAnimator.Start();
                mAnimator.AnimationEnd += (object IntentSender, EventArgs arg) =>
                {
                    ListeHaznesi.Visibility = ViewStates.Gone;
                };
                durum = false;
            }
        }
예제 #4
0
 protected override void OnLayout(bool changed, int l, int t, int r, int b)
 {
     surfaceViewPlaceholder.Measure(
         MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly),
         MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly));
     surfaceViewPlaceholder.Layout(0, 0, r - l, b - t);
 }
예제 #5
0
        public void AcKapat()
        {
            int sayac1 = CizimHaznesi.Height;

            if (durum == false) //kapalı
            {
                CizimHaznesi.Visibility = ViewStates.Visible;
                int widthSpec  = View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);
                int heightSpec = View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);
                CizimHaznesi.Measure(widthSpec, heightSpec);

                DisplayMetrics displayMetrics = new DisplayMetrics();
                WindowManager.DefaultDisplay.GetMetrics(displayMetrics);
                int           screenheight = displayMetrics.HeightPixels;
                ValueAnimator mAnimator    = slideAnimator(0, screenheight);
                mAnimator.AnimationStart += MAnimator_AnimationStart;
                mAnimator.AnimationEnd   += MAnimator_AnimationEnd;
                mAnimator.Start();

                durum = true;
            }
            else if (durum == true)//Acik
            {
                int finalHeight = CizimHaznesi.Height;

                ValueAnimator mAnimator = slideAnimator(finalHeight, 0);
                mAnimator.AnimationStart += MAnimator_AnimationStart1;
                mAnimator.Start();
                mAnimator.AnimationEnd += (object IntentSender, EventArgs arg) =>
                {
                    CizimHaznesi.Visibility = ViewStates.Gone;
                };
                durum = false;
            }
        }
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);

            if (nativeView != null)
            {
                var msw = MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly);
                var msh = MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly);

                nativeView.Measure(msw, msh);
                nativeView.Layout(0, 0, r - l, b - t);
            }
        }
        public static Bitmap ToBitmap(this AView view)
        {
            var layout = new FrameLayout(view.Context);

            layout.LayoutParameters = new FrameLayout.LayoutParams(500, 500);
            view.LayoutParameters   = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WrapContent, FrameLayout.LayoutParams.WrapContent)
            {
                Gravity = GravityFlags.Center
            };

            layout.AddView(view);
            layout.Measure(500, 500);
            layout.Layout(0, 0, 500, 500);
            var    bitmap = Bitmap.CreateBitmap(view.Width, view.Height, Bitmap.Config.Argb8888);
            Canvas canvas = new Canvas(bitmap);

            view.Layout(0, 0, view.Width, view.Height);
            view.Draw(canvas);

            return(bitmap);
        }