コード例 #1
0
        void ChangeTheme(IColoredPage page)
        {
            var basePage = page as IColoredPage;

            if (basePage != null)
            {
                if ((int)Android.OS.Build.VERSION.SdkInt >= 21)
                {
                    SetThemeColors(basePage);
                }
            }
        }
コード例 #2
0
        private void SetThemeColors(IColoredPage basePage)
        {
            var context = Context as Activity;

            if (context != null)
            {
                context.Window.ClearFlags(WindowManagerFlags.TranslucentStatus);
                context.Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
                context.Window.SetNavigationBarColor(basePage.NavigationBarColor.ToAndroid());
                context.Window.SetStatusBarColor(basePage.StatusBarColor.ToAndroid());

                var           actionBar     = context.ActionBar;
                ColorDrawable colorDrawable = new ColorDrawable(basePage.ActionBarBackgroundColor.ToAndroid());
                actionBar.SetBackgroundDrawable(colorDrawable);
            }
        }
コード例 #3
0
        private void SetThemeColors(IColoredPage basePage)
        {
            var context = Context as Activity;

            if (context != null)
            {
                context.Window.SetNavigationBarColor(basePage.NavigationBarColor.ToAndroid());
                context.Window.SetStatusBarColor(basePage.StatusBarColor.ToAndroid());

                var           actionBar     = context.ActionBar;
                ColorDrawable colorDrawable = new ColorDrawable(basePage.ActionBarBackgroundColor.ToAndroid());
                actionBar.SetBackgroundDrawable(colorDrawable);

                int titleId = context.Resources.GetIdentifier("action_bar_title", "id", "android");


                var page = basePage as Page;
                if (page == null)
                {
                    return;
                }
                if (page.Title == "Foods")
                {
                    var basketMenu = page.ToolbarItems.FirstOrDefault(t => t.ClassId == "basket");
                    //page.ToolbarItems.Remove(basketMenu);
                    var tempContext = context as MainActivity;
                    if (tempContext != null)
                    {
                        //tempContext.SetActionBar()
                    }
                }
            }

            //TextView abTitle = (TextView)context.FindViewById(titleId);
            //abTitle.SetTextColor(basePage.BarTextColor.ToAndroid());
        }