Beispiel #1
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            AppCompatImageButton search = null;

            for (int i = 0; i < _toolBar.ChildCount; i++)
            {
                if (_toolBar.GetChildAt(i) is AppCompatImageButton)
                {
                    search = (AppCompatImageButton)_toolBar.GetChildAt(i);
                }
            }

            this._toolBar.SetBackgroundColor(Android.Graphics.Color.Rgb(33, 150, 243));

            if ((Element as CustomSearchPage).ChangePage == 2)
            {
                navigationPush = true;
            }
            else if ((Element as CustomSearchPage).ChangePage == 1 && search != null)
            {
                AddSearchToToolBar(); (Element as CustomSearchPage).ChangePage = 0;
            }
            else if ((Element as CustomSearchPage).ChangePage == 1 && navigationPush)
            {
                AddSearchToToolBar(); (Element as CustomSearchPage).ChangePage = 0; navigationPush = false;
            }
            else if (search == null)
            {
                (Element as CustomSearchPage).ChangePage = 0;
            }
        }
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);
            for (int i = 0; i < toolbar.ChildCount; i++)
            {
                var item = toolbar.GetChildAt(i);

                if (item.GetType() == typeof(TextView))
                {
                    TextView tv = item as TextView;
                    tv.SetTypeface(Android.Graphics.Typeface.Serif, Android.Graphics.TypefaceStyle.Italic);
                }
            }
        }
Beispiel #3
0
        void SetTitle()
        {
            if (GetToolbar() != null)
            {
                for (var i = 0; i < toolbar.ChildCount; i++)
                {
                    var Title = toolbar.GetChildAt(i);
                    if (Title is TextView title)
                    {
                        if (TitleHorizontalAlignment == HorizontalAlignmentEnum.Center)
                        {
                            float toolbarCenter = toolbar.Width / 2;
                            float titleCenter   = title.Width / 2;
                            title.SetX(toolbarCenter - titleCenter);
                        }

                        if (!string.IsNullOrWhiteSpace(FontFamily))
                        {
                            var typeface = Typeface.Create(FontFamily, ConvertFontAttributesToTypefaceStyle(TitleFontAttributes));
                            title.Typeface = typeface;
                        }

                        if (TitleFontSize != 0)
                        {
                            title.TextSize = TitleFontSize;
                        }
                    }
                }
            }
        }
Beispiel #4
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);

            // Center title
            for (int i = 0; i < _toolBar?.ChildCount; i++)
            {
                if (_toolBar.GetChildAt(i) is TextView titleView)
                {
                    var toolbarCenter = _toolBar.Width / 2;
                    var titleCenter   = titleView.Width / 2;
                    titleView.SetX(toolbarCenter - titleCenter);
                }
            }
        }
Beispiel #5
0
        public void AddSearchToToolBar()
        {
            _toolBar.Title = "XamControls"; //Element.Title;

            //_toolBar.Menu.GetItem(0).SetIcon();

            InitializeSearchView();

            if (_toolBar?.GetChildAt(1) is AppCompatTextView)
            {
                actionMenuView       = (Android.Support.V7.Widget.ActionMenuView)_toolBar?.GetChildAt(0);
                appCompatTextView    = (AppCompatTextView)_toolBar?.GetChildAt(1);
                appCompatImageButton = (AppCompatImageButton)_toolBar?.GetChildAt(2);
            }
            else
            {
                actionMenuView       = (Android.Support.V7.Widget.ActionMenuView)_toolBar?.GetChildAt(0);
                appCompatImageButton = (AppCompatImageButton)_toolBar?.GetChildAt(1);
                appCompatTextView    = (AppCompatTextView)_toolBar?.GetChildAt(2);
            }
        }