예제 #1
0
        public void InitializeInstruction(params View[] contentViews)
        {
            contentHeight = 0;
            ViewGroup containerView = FindViewById <RelativeLayout>(Resource.Id.MainLayout);

            LayoutInflater inflater = LayoutInflater.From(this);
            View           instructionLayoutView = inflater.Inflate(Resource.Layout.Instruction, containerView);

            TextView instructionTextView = instructionLayoutView.FindViewById <TextView>(Resource.Id.instructionTextView);
            TextView descriptionTextView = instructionLayoutView.FindViewById <TextView>(Resource.Id.descriptionTextView);

            descriptionTextView.Text = "Draw and Edit Shapes.";

            LinearLayout instructionLayout = instructionLayoutView.FindViewById <LinearLayout>(Resource.Id.instructionLinearLayout);
            LinearLayout contentLayout     = instructionLayoutView.FindViewById <LinearLayout>(Resource.Id.contentLinearLayout);

            RelativeLayout headerRelativeLayout = instructionLayoutView.FindViewById <RelativeLayout>(Resource.Id.headerRelativeLayout);

            if (contentViews != null)
            {
                foreach (View view in contentViews)
                {
                    contentLayout.AddView(view);
                }
            }

            headerRelativeLayout.Click += (sender, e) =>
            {
                contentHeight = contentHeight == 0 ? instructionLayout.Height - instructionTextView.Height : -contentHeight;
                instructionLayout.Layout(instructionLayout.Left, instructionLayout.Top + contentHeight, instructionLayout.Right, instructionLayout.Bottom);
            };
        }
예제 #2
0
        /**
         * Creates an icon with the current content and style.
         * <p/>
         * This method is useful if a custom view has previously been set, or if text content is not
         * applicable.
         */

        public Bitmap MakeIcon()
        {
            int measureSpec = View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);

            mContainer.Measure(measureSpec, measureSpec);

            int measuredWidth  = mContainer.MeasuredWidth;
            int measuredHeight = mContainer.MeasuredHeight;

            mContainer.Layout(0, 0, measuredWidth, measuredHeight);

            Bitmap r = Bitmap.CreateBitmap(measuredWidth, measuredHeight, Bitmap.Config.Argb8888);

            r.EraseColor(Color.Transparent);

            Canvas canvas = new Canvas(r);

            canvas.DrawColor(Color.White, PorterDuff.Mode.SrcIn);
            Drawable drawable = mContainer.Background;

            if (drawable != null)
            {
                drawable.Draw(canvas);
            }
            mContainer.Draw(canvas);
            return(r);
        }
예제 #3
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);
            var msw = Android.Views.View.MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly);
            var msh = Android.Views.View.MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly);

            layout.Measure(msw, msh);
            layout.Layout(0, 0, r - l, b - t);
        }
예제 #4
0
 /// <summary>
 /// Called when this view should assign a size and position to all of its children.
 /// <para> A Caveat of this is that always measure this based on the root most of the layout. in this case, linearlayout.
 /// For example, in the parent class, we did the measure on viewpager itself since it is the rootmost of the class</para>
 /// </summary>
 /// <param name="changed">if set to <c>true</c> This will be the new size or position for this view.</param>
 /// <param name="l">Left position, relative to parent.</param>
 /// <param name="t">Top position, relative to parent.</param>
 /// <param name="r">Right position, relative to parent.</param>
 /// <param name="b">Bottom position, relative to parent.</param>
 protected override void OnLayout(bool changed, int l, int t, int r, int b)
 {
     base.OnLayout(changed, l, t, r, b);
     if (linearLayout == null)
     {
         return;
     }
     linearLayout.Measure(MakeMeasureSpec(r - l, MeasureSpecMode.Exactly), MakeMeasureSpec(b - t, MeasureSpecMode.Exactly));
     linearLayout.Layout(0, 0, r - l, b - t);
 }
예제 #5
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            int headerLeft   = r - l - _headers.MeasuredWidth - PaddingRight;
            int headerRight  = headerLeft + _headers.MeasuredWidth;
            int headerTop    = t;//b - t;// - _headers.MeasuredHeight - PaddingBottom;
            int headerBottom = headerTop + _headers.MeasuredHeight;

            _headers.Layout(headerLeft, headerTop, headerRight, headerBottom);

            int rowLeft   = headerLeft;
            int rowRight  = r; // rowLeft + _rows.MeasuredWidth;
            int rowTop    = headerBottom;
            int rowBottom = b; // rowTop + _rows.MeasuredHeight;

            _rows.Layout(rowLeft, rowTop, rowRight, rowBottom);
        }
        void InitView()
        {
            NotchLayout = new LinearLayout(Container.Context);
            NotchLayout.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, Android.Views.ViewGroup.LayoutParams.MatchParent);


            var button = new Android.Widget.Button(Container.Context);

            button.Text = "Notch";

            var page = Element as Page;

            if (NotchInfo.Model == PhoneModels.Custom)
            {
                Device = NotchInfo.CustomDevice;
            }
            else
            {
                Device = Devices[NotchInfo.Model];
            }


            var notch = new NotchView(Container.Context)
            {
                Device = Device
            };

            NotchLayout.AddView(notch);
            Container.AddView(NotchLayout);

            NotchLayout.Parent.BringChildToFront(NotchLayout);


            Container.LayoutChange += (sender, e) =>
            {
                if (NotchLayout != null)
                {
                    var msw = MeasureSpec.MakeMeasureSpec(e.Right, MeasureSpecMode.Exactly);
                    var msh = MeasureSpec.MakeMeasureSpec(e.Bottom, MeasureSpecMode.Exactly);

                    NotchLayout.Measure(msw, msh);
                    NotchLayout.Layout(0, 0, e.Right, e.Bottom);

                    NotchLayout.Parent.BringChildToFront(NotchLayout);
                }
            };
        }
예제 #7
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);

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

                _androidLinearLayout.Measure(msw, msh);
                _androidLinearLayout.Layout(0, 0, r - l, b - t);
                if (webView != null)
                {
                    webView.Measure(msw, msh);
                    webView.Layout(0, (int)toolbarHeight, r - l, b - t);
                }
            }
        }
예제 #8
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            Context context = Context;
            int     width   = r - l;
            int     height  = b - t;

            rootView.Measure(AppCompat.MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.AtMost), AppCompat.MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.AtMost));

            if (width > 0 && height > 0)
            {
                if (Element.HasSearchBar)
                {
                    PageController.ContainerArea = new Rectangle(0, 0, context.FromPixels(width), context.FromPixels(height - searchContainer.MeasuredHeight));
                }
                else
                {
                    PageController.ContainerArea = new Rectangle(0, 0, context.FromPixels(width), context.FromPixels(height));
                }
                rootView.Layout(0, 0, width, b);
            }

            base.OnLayout(changed, l, t, r, b);
        }
예제 #9
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            int width  = r - l;
            int height = b - t;

            if (width > 0 && height > 0)
            {
                var context = Context;
                _rootLayout.Measure(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.AtMost), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.AtMost));
                _rootLayout.Layout(0, 0, _rootLayout.MeasuredWidth, _rootLayout.MeasuredHeight);

                _bottomBar.Measure(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.AtMost));
                int tabsHeight = BottomBarHeight.HasValue ? (int)Context.ToPixels(BottomBarHeight.Value) : Math.Min(height, Math.Max(_bottomBar.MeasuredHeight, _bottomBar.MinimumHeight));

                _frameLayout.Layout(0, 0, width, height - tabsHeight);

                _pageController.ContainerArea = new Rectangle(0, 0, context.FromPixels(width), context.FromPixels(_frameLayout.Height));

                _bottomBar.Layout(0, height - tabsHeight, width, height);
            }

            base.OnLayout(changed, l, t, r, b);
        }
 /// <inheritdoc />
 protected override void OnLayout(bool changed, int l, int t, int r, int b)
 {
     // Forward layout call to the root layout
     _rootLayout.Layout(PaddingLeft, PaddingTop, _rootLayout.MeasuredWidth + PaddingLeft, _rootLayout.MeasuredHeight + PaddingBottom);
 }
예제 #11
0
 private static void HeaderRelativeLayoutClick(object sender, EventArgs e)
 {
     contentHeight = contentHeight == 0 ? instructionLayout.Height - instructionTextView.Height : -contentHeight;
     instructionLayout.Layout(instructionLayout.Left, instructionLayout.Top + contentHeight, instructionLayout.Right, instructionLayout.Bottom);
 }