C# Shell选项卡栏圆角覆盖后面的默认背景色(视图)

C# Shell选项卡栏圆角覆盖后面的默认背景色(视图),c#,xamarin.forms,custom-renderer,xamarin.forms.shell,C#,Xamarin.forms,Custom Renderer,Xamarin.forms.shell,我在Shell选项卡上应用圆角,如中所示 我的问题:是否可以将视图(背景色)放在后面而不是上面(默认黑色) 您可以将父级的BackgroundColor设置为当前ContentPageBackgroundColor或其Content(可能是布局)BackgroundColor public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance) {

我在Shell选项卡上应用圆角,如中所示

我的问题:是否可以将视图(背景色)放在后面而不是上面(默认黑色)


您可以将父级的
BackgroundColor
设置为当前
ContentPage
BackgroundColor
或其
Content
(可能是布局)
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);
        }

由于这是一个后续问题,我只是针对这个问题给出了相关的代码,完整的代码可以在

中找到。您可以定义可绘制的背景,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="#ffffff" />
        </shape>
    </item>
    <item>
        <shape xmlns:android="http://schemas.android.com/apk/res/android">
            <solid android:color="#f00" />
            <corners android:topLeftRadius="20dp" android:topRightRadius="20dp" />
        </shape>
    </item>
</layer-list>

你确定你链接的问题是关于设置圆角的吗?哦,不,错了。我编辑过。这个解决方案的问题是
这是真的,它是硬编码的,但是当您的视图中有相同的背景颜色时,它是一个有效的解决方案。我正在尝试使用相同的可绘制背景文件。同意这是一个有效的解决方案,我刚才指出了这种情况,因为我自己在发现这可能会给扫描带来不便之前,已经对颜色进行了硬编码。如果它回答了您的问题,或者您觉得它很有用,请让我知道,否则您可能会给我留下反馈/评论。
bottomView.SetBackgroundResource(Resource.Drawable.bottombackground);
bottomView.Elevation = 0;