示例#1
0
        private void applyTo(View target)
        {
            Android.Views.ViewGroup.LayoutParams lp     = target.LayoutParameters;
            Android.Views.IViewParent            parent = target.Parent;
            FrameLayout container = new FrameLayout(context);

            if (target is TabWidget)
            {
                // set target to the relevant tab child container
                target      = ((TabWidget)target).GetChildTabViewAt(targetTabIndex);
                this.target = target;

                ((ViewGroup)target).AddView(container,
                                            new Android.Views.ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.FillParent, Android.Views.ViewGroup.LayoutParams.FillParent));

                this.Visibility = (ViewStates.Gone);
                container.AddView(this);
            }
            else
            {
                // TODO verify that parent is indeed a ViewGroup
                ViewGroup group = (ViewGroup)parent;
                int       index = group.IndexOfChild(target);

                group.RemoveView(target);
                group.AddView(container, index, lp);

                container.AddView(target);

                this.Visibility = (ViewStates.Gone);
                container.AddView(this);

                group.Invalidate();
            }
        }
示例#2
0
        private void moveToBack(View myCurrentView)
        {
            ViewGroup myViewGroup = ((ViewGroup)myCurrentView.Parent);
            int       index       = myViewGroup.IndexOfChild(myCurrentView);

            for (int i = 0; i < index; i++)
            {
                myViewGroup.BringChildToFront(myViewGroup.GetChildAt(i));
            }
        }
示例#3
0
        public static void replaceView(View currentView, View newView)
        {
            ViewGroup parent = getParent(currentView);

            if (parent == null)
            {
                return;
            }
            int index = parent.IndexOfChild(currentView);

            removeView(currentView);
            removeView(newView);
            parent.AddView(newView, index);
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View layout = base.OnCreateView(inflater, container, savedInstanceState);

            ListView  lv     = (ListView)layout.FindViewById(Android.Resource.Id.List);
            ViewGroup parent = (ViewGroup)lv.Parent;

            // Remove ListView and add PullToRefreshListView in its place
            int lvIndex = parent.IndexOfChild(lv);

            parent.RemoveViewAt(lvIndex);
            mPullToRefreshListView = onCreatePullToRefreshListView(inflater, savedInstanceState);
            parent.AddView(mPullToRefreshListView, lvIndex, lv.LayoutParameters);

            return(layout);
        }
示例#5
0
        private void checkZPosition()
        {
            // If the toast isn't visible, no point in updating all the views
            if (!mVisible)
            {
                return;
            }
            int pos   = mParentView.IndexOfChild(mView);
            int count = mParentView.ChildCount;

            if (pos != count - 1)
            {
                ((ViewGroup)mView.Parent).RemoveView(mView);
                mParentView.RequestLayout();
                mParentView.AddView(mView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
            }
        }
示例#6
0
            private void ApplyTo(View target)
            {
                var         lp        = target.LayoutParameters;
                IViewParent parent    = target.Parent;
                FrameLayout container = new FrameLayout(context);

                // borrow some properties from the view which the badge is being applied
                this.Clickable            = target.Clickable;
                this.Focusable            = target.Focusable;
                this.FocusableInTouchMode = target.FocusableInTouchMode;

                if (target is TabWidget)
                {
                    target      = ((TabWidget)target).GetChildTabViewAt(targetTabIndex);
                    this.target = target;

                    ((ViewGroup)target).AddView(
                        container,
                        new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent)
                        );

                    Visibility = ViewStates.Gone;
                    container.AddView(this);
                }
                else
                {
                    ViewGroup group = (ViewGroup)parent;                        // will throw an exception if not actually a ViewGroup
                    int       index = group.IndexOfChild(target);

                    group.RemoveView(target);
                    group.AddView(container, index, lp);

                    container.AddView(target);

                    Visibility = ViewStates.Gone;
                    container.AddView(this);

                    group.Invalidate();
                }
            }