예제 #1
0
        public static void SetupTabItems(this BottomTabbedRenderer renderer, BottomNavigationViewEx bottomNav)
        {
            var Element = renderer.Element;
            var menu    = (BottomNavigationMenu)bottomNav.Menu;

            menu.Clear();
            var mPresenterField = Java.Lang.Class.FromType(typeof(BottomNavigationMenuView)).GetDeclaredField("presenter");

            mPresenterField.Accessible = true;
            var mPresenter = (BottomNavigationPresenter)mPresenterField.Get(bottomNav.BottomNavigationMenuView);

            mPresenterField.Accessible = false;

            if (Element.Children.Count == 0)
            {
                return;
            }

            mPresenter.SetUpdateSuspended(true);
            var tabsCount = Math.Min(Element.Children.Count, bottomNav.MaxItemCount);

            for (int i = 0; i < tabsCount; i++)
            {
                var page     = Element.Children[i];
                var menuItem = menu.Add(0, i, 0, page.Title);
                var setter   = BottomTabbedRenderer.MenuItemIconSetter ?? BottomTabbedRenderer.DefaultMenuItemIconSetter;
                setter.Invoke(menuItem, page.IconImageSource as FileImageSource, renderer.LastSelectedIndex == i);
            }
            mPresenter.SetUpdateSuspended(false);
            mPresenter.UpdateMenuView(true);
            //Deprecated use {@link #setLabelVisibilityMode }
            bottomNav.EnableShiftingMode(false);     //enable It will has a shift animation if true. Otherwise all items are the same width.
            //Deprecated use {@link #setItemHorizontalTranslationEnabled(boolean)}
            bottomNav.EnableItemShiftingMode(false); //enable It will has a shift animation for item if true. Otherwise the item text always be shown.
            bottomNav.EnableAnimation(false);        //enable It means the text won't scale and icon won't move when active it in no item shifting mode if false.
            bottomNav.SetTextVisibility(BottomTabbedRenderer.VisibleTitle.HasValue ? BottomTabbedRenderer.VisibleTitle.Value : true);
            if (BottomTabbedRenderer.Typeface != null)
            {
                bottomNav.SetTypeface(BottomTabbedRenderer.Typeface);
            }
            if (BottomTabbedRenderer.IconSize.HasValue)
            {
                bottomNav.SetIconSize(BottomTabbedRenderer.IconSize.Value, BottomTabbedRenderer.IconSize.Value);
            }
            if (BottomTabbedRenderer.FontSize.HasValue)
            {
                bottomNav.SetTextSize(BottomTabbedRenderer.FontSize.Value);
            }

            bottomNav.TextAlignment = Android.Views.TextAlignment.Center;
        }
        public static void SetupTabItems(this BottomTabbedRenderer renderer, BottomNavigationViewEx bottomNav)
        {
            var Element = renderer.Element;
            var menu    = (BottomNavigationMenu)bottomNav.Menu;

            menu.Clear();
            var mPresenterField = Java.Lang.Class.FromType(typeof(BottomNavigationMenuView)).GetDeclaredField("presenter");

            mPresenterField.Accessible = true;
            var mPresenter = (BottomNavigationPresenter)mPresenterField.Get(bottomNav.BottomNavigationMenuView);

            mPresenterField.Accessible = false;

            if (Element.Children.Count == 0)
            {
                return;
            }

            mPresenter.SetUpdateSuspended(true);
            var tabsCount = Math.Min(Element.Children.Count, bottomNav.MaxItemCount);

            for (int i = 0; i < tabsCount; i++)
            {
                var page     = Element.Children[i];
                var menuItem = menu.Add(0, i, 0, page.Title);
                var setter   = BottomTabbedRenderer.MenuItemIconSetter ?? BottomTabbedRenderer.DefaultMenuItemIconSetter;
                setter.Invoke(menuItem, page.Icon, renderer.LastSelectedIndex == i);
            }
            mPresenter.SetUpdateSuspended(false);
            mPresenter.UpdateMenuView(true);

            bottomNav.EnableShiftingMode(false);     //remove shifting mode
            bottomNav.EnableItemShiftingMode(false); //remove shifting mode
            bottomNav.EnableAnimation(false);        //remove animation
            bottomNav.SetTextVisibility(BottomTabbedRenderer.VisibleTitle.HasValue ? BottomTabbedRenderer.VisibleTitle.Value : true);
            if (BottomTabbedRenderer.Typeface != null)
            {
                bottomNav.SetTypeface(BottomTabbedRenderer.Typeface);
            }
            if (BottomTabbedRenderer.IconSize.HasValue)
            {
                bottomNav.SetIconSize(BottomTabbedRenderer.IconSize.Value, BottomTabbedRenderer.IconSize.Value);
            }
            if (BottomTabbedRenderer.FontSize.HasValue)
            {
                bottomNav.SetTextSize(BottomTabbedRenderer.FontSize.Value);
            }

            bottomNav.TextAlignment = Android.Views.TextAlignment.Center;
        }
        public static void SetupTabItems(this ExtendedTabbedPageRenderer renderer, BottomNavigationViewEx bottomNav)
        {
            var element = renderer.Element;
            var menu    = (BottomNavigationMenu)bottomNav.Menu;

            menu.ClearAll();

            var tabsCount = Math.Min(element.Children.Count, bottomNav.MaxItemCount);

            for (int i = 0; i < tabsCount; i++)
            {
                var page     = element.Children[i];
                var menuItem = menu.Add(0, i, 0, page.Title);
                var setter   = ExtendedTabbedPageRenderer.MenuItemIconSetter ?? ExtendedTabbedPageRenderer.DefaultMenuItemIconSetter;
                setter.Invoke(menuItem, page.Icon, renderer.LastSelectedIndex == i);
            }

            if (element.Children.Count > 0)
            {
                bottomNav.EnableShiftingMode(false);
                bottomNav.EnableItemShiftingMode(false);
                bottomNav.EnableAnimation(false);
                bottomNav.SetTextVisibility(false);
                bottomNav.SetBackgroundResource(Resource.Drawable.bottom_nav_bg);
                bottomNav.SetIconSize(24, 24);
                bottomNav.SetIconsMarginTop(32);

                if (element.Children.Count > 3)
                {
                    bottomNav.SetIconSizeAt(3, 29, 29);
                    bottomNav.SetIconMarginTop(3, 28);
                }

                var stateList = new global::Android.Content.Res.ColorStateList(
                    new int[][] {
                    new int[] { global::Android.Resource.Attribute.StateChecked },
                    new int[] { global::Android.Resource.Attribute.StateEnabled }
                },
                    new int[] {
                    element.TintColor.ToAndroid(),      // Selected
                    Color.FromHex("A1A1A1").ToAndroid() // Normal
                });

                bottomNav.ItemIconTintList = stateList;
            }
        }
        public static void SetupTabItems(this BottomTabbedRenderer renderer, BottomNavigationViewEx bottomNav)
        {
            var Element = renderer.Element;
            var menu    = (BottomNavigationMenu)bottomNav.Menu;

            menu.ClearAll();

            var tabsCount = Math.Min(Element.Children.Count, bottomNav.MaxItemCount);

            for (int i = 0; i < tabsCount; i++)
            {
                var page     = Element.Children[i];
                var menuItem = menu.Add(0, i, 0, page.Title);
                var setter   = BottomTabbedRenderer.MenuItemIconSetter ?? BottomTabbedRenderer.DefaultMenuItemIconSetter;
                setter.Invoke(menuItem, page.Icon, renderer.LastSelectedIndex == i);
            }
            if (Element.Children.Count > 0)
            {
                bottomNav.EnableShiftingMode(false);     //remove shifting mode
                bottomNav.EnableItemShiftingMode(false); //remove shifting mode
                bottomNav.EnableAnimation(false);        //remove animation
                bottomNav.SetTextVisibility(BottomTabbedRenderer.VisibleTitle.HasValue ? BottomTabbedRenderer.VisibleTitle.Value : true);
                if (BottomTabbedRenderer.Typeface != null)
                {
                    bottomNav.SetTypeface(BottomTabbedRenderer.Typeface);
                }
                if (BottomTabbedRenderer.IconSize.HasValue)
                {
                    bottomNav.SetIconSize(BottomTabbedRenderer.IconSize.Value, BottomTabbedRenderer.IconSize.Value);
                }
                if (BottomTabbedRenderer.FontSize.HasValue)
                {
                    bottomNav.SetTextSize(BottomTabbedRenderer.FontSize.Value);
                }

                bottomNav.TextAlignment = Android.Views.TextAlignment.Center;
            }
        }
예제 #5
0
        public void initInterface()
        {
            bnve_normal                          = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_normal);
            bnve_no_animation                    = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_animation);
            bnve_no_shifting_mode                = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_shifting_mode);
            bnve_no_item_shifting_mode           = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_item_shifting_mode);
            bnve_no_text                         = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_text);
            bnve_no_icon                         = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_icon);
            bnve_no_animation_shifting_mode      = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_animation_shifting_mode);
            bnve_no_animation_item_shifting_mode = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_animation_item_shifting_mode);
            bnve_no_animation_shifting_mode_item_shifting_mode      = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_animation_shifting_mode_item_shifting_mode);
            bnve_no_shifting_mode_item_shifting_mode_text           = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_shifting_mode_item_shifting_mode_text);
            bnve_no_animation_shifting_mode_item_shifting_mode_text = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_animation_shifting_mode_item_shifting_mode_text);
            bnve_no_shifting_mode_item_shifting_mode_and_icon       = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_shifting_mode_item_shifting_mode_and_icon);
            bnve_no_item_shifting_mode_icon = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_item_shifting_mode_icon);
            bnve_no_animation_shifting_mode_item_shifting_mode_icon = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_animation_shifting_mode_item_shifting_mode_icon);
            bnve_with_padding     = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_with_padding);
            bnve_center_icon_only = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_center_icon_only);
            bnve_smaller_text     = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_smaller_text);
            bnve_bigger_icon      = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_bigger_icon);
            bnve_custom_typeface  = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_custom_typeface);
            bnve_icon_selector    = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_icon_selector);

            //no animation
            bnve_no_animation.EnableAnimation(false);

            //no shifting mode
            bnve_no_shifting_mode.EnableShiftingMode(false);

            //no item shifting mode
            bnve_no_item_shifting_mode.EnableItemShiftingMode(false);

            //bnve no text
            bnve_no_text.SetTextVisibility(false);

            //bnve no icon
            bnve_no_icon.SetIconVisibility(false);

            //bnve no animation shifting mode
            bnve_no_animation_shifting_mode.EnableAnimation(false);
            bnve_no_animation_shifting_mode.EnableShiftingMode(false);

            //bnve_no_animation_item_shifting_mode
            bnve_no_animation_shifting_mode_item_shifting_mode.EnableAnimation(false);
            bnve_no_animation_shifting_mode_item_shifting_mode.EnableItemShiftingMode(false);

            //bnve_no_animation_shifting_mode_item_shifting_mode
            bnve_no_animation_shifting_mode_item_shifting_mode.EnableAnimation(false);
            bnve_no_animation_shifting_mode_item_shifting_mode.EnableShiftingMode(false);
            bnve_no_animation_shifting_mode_item_shifting_mode.EnableItemShiftingMode(false);

            //bnve_no_shifting_mode_item_shifting_mode_text
            bnve_no_shifting_mode_item_shifting_mode_text.EnableItemShiftingMode(false);
            bnve_no_shifting_mode_item_shifting_mode_text.EnableShiftingMode(false);
            bnve_no_shifting_mode_item_shifting_mode_text.SetTextVisibility(false);

            //bnve_no_animation_shifting_mode_item_shifting_mode_text
            bnve_no_animation_shifting_mode_item_shifting_mode_text.EnableAnimation(false);
            bnve_no_animation_shifting_mode_item_shifting_mode_text.EnableShiftingMode(false);
            bnve_no_animation_shifting_mode_item_shifting_mode_text.EnableItemShiftingMode(false);

            //bnve_no_shifting_mode_item_shifting_mode_and_icon
            bnve_no_shifting_mode_item_shifting_mode_and_icon.EnableItemShiftingMode(false);
            bnve_no_shifting_mode_item_shifting_mode_and_icon.EnableShiftingMode(false);
            bnve_no_shifting_mode_item_shifting_mode_and_icon.SetIconVisibility(false);

            //bnve_no_item_shifting_mode_icon
            bnve_no_item_shifting_mode_icon.EnableItemShiftingMode(false);
            bnve_no_item_shifting_mode_icon.SetIconVisibility(false);

            //bnve_no_animation_shifting_mode_item_shifting_mode_icon
            bnve_no_animation_shifting_mode_item_shifting_mode_icon.EnableAnimation(false);
            bnve_no_animation_shifting_mode_item_shifting_mode_icon.EnableItemShiftingMode(false);
            bnve_no_animation_shifting_mode_item_shifting_mode_icon.EnableShiftingMode(false);
            bnve_no_animation_shifting_mode_item_shifting_mode_icon.SetIconVisibility(false);

            //bnve_with_padding
            bnve_with_padding.SetPadding(8, 8, 8, 8);

            //bnve_center_icon_only

            //bnve_smaller_text
            bnve_smaller_text.SetTextSize(10);

            //bnve_bigger_icon
            bnve_bigger_icon.SetIconSize(48, 48);
            bnve_bigger_icon.SetTextVisibility(false);

            //bnve_custom_typeface
            Android.Graphics.Typeface typeface = Android.Graphics.Typeface.CreateFromAsset(this.Assets, "fonts/JOKERMAN.TTF");
            bnve_custom_typeface.SetTypeface(typeface);

            //bnve_icon_selector
        }