Shell TabBar 圆角覆盖后面的默认背景颜色(视图) [英] Shell TabBar rounded corners override default background color (View) behind

查看:39
本文介绍了Shell TabBar 圆角覆盖后面的默认背景颜色(视图)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Shell TabBar 上应用圆角,例如

解决方案

您可以将 Parent 的 BackgroundColor 设置为当前 ContentPage BackgroundColor 或者它 Content(可能是一个布局)BackgroundColor.

 public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement 外观){var currentContentPage = (Shell.Current.CurrentPage as ContentPage);if (currentContentPage == null){返回;}if (currentContentPage.Content != null && currentContentPage.Content.BackgroundColor != Color.Transparent){(bottomView.Parent as LinearLayout)?.SetBackgroundColor(currentContentPage.Content.BackgroundColor.ToAndroid());}别的{(bottomView.Parent as LinearLayout)?.SetBackgroundColor(currentContentPage.BackgroundColor.ToAndroid());}bottomView.SetBackgroundResource(Resource.Drawable.bottombackground);}

注意

由于是后续问题,所以我只放了针对这个问题的相关代码,完整代码可以在https://stackoverflow.com/a/65784730>/stackoverflow.com/a/65784730

I'm applying rounded corner on a Shell TabBar like in Xamarin Forms Shell TabBar Rounded Corner.

My question: is it possible to put the view (background color) behind instead of above (default black color)?

解决方案

You can set the BackgroundColor of the Parent to either the current ContentPage BackgroundColor or to it Content (probably a Layout) BackgroundColor.

    public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance)
        {
            var currentContentPage = (Shell.Current.CurrentPage as ContentPage);
            if (currentContentPage == null)
            {
                return;
            }

            if (currentContentPage.Content != null && currentContentPage.Content.BackgroundColor != Color.Transparent)
            {
                (bottomView.Parent as LinearLayout)?.SetBackgroundColor(currentContentPage.Content.BackgroundColor.ToAndroid());
            }
            else
            {
                (bottomView.Parent as LinearLayout)?.SetBackgroundColor(currentContentPage.BackgroundColor.ToAndroid());
            }

            bottomView.SetBackgroundResource(Resource.Drawable.bottombackground);
        }

Note

Since it is a follow-up question I just put the relevant code specific for this question, the full code could be found in https://stackoverflow.com/a/65784730

这篇关于Shell TabBar 圆角覆盖后面的默认背景颜色(视图)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆