[英]Shell flyout with round corners
尝试通过设置圆角半径来自定义 Shell 弹出按钮,以便获得带有圆角的弹出按钮。 由于没有与 Shell 弹出角半径相关的属性,有没有办法使用自定义渲染器来实现?
不幸的是,当使用基于 AppShell 层次结构的自动生成的弹出内容时,我看不到在共享代码中执行此操作的方法(如果您要覆盖它,请跳到编辑部分),这是使用自定义完成它的解决方案Android 的渲染器:
Resources\drawable
中,添加:flyoutbackground.xml
<?xml version="1.0" encoding="utf-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/transparent" />
<corners android:bottomRightRadius="30dp" android:topRightRadius="30dp" />
</shape>
ShellRenderer
:[assembly: ExportRenderer(typeof(App1.AppShell), typeof(AppShellRenderer))]
namespace App1.Droid.Renderers
{
public class AppShellRenderer : ShellRenderer
{
public AppShellRenderer(Context context) : base(context)
{
}
protected override IShellFlyoutContentRenderer CreateShellFlyoutContentRenderer()
{
var flyoutContentRenderer = base.CreateShellFlyoutContentRenderer();
var flyoutbackground = AppCompatResources.GetDrawable(Platform.CurrentActivity, Resource.Drawable.flyoutbackground);
if (Android.OS.Build.VERSION.SdkInt > Android.OS.BuildVersionCodes.O)
{
flyoutbackground.SetColorFilter(new BlendModeColorFilter(
Shell.Current.FlyoutBackgroundColor.ToAndroid(), BlendMode.Color));
flyoutContentRenderer.AndroidView.SetBackground(flyoutbackground);
}
else
{
flyoutbackground.SetColorFilter(Shell.Current.FlyoutBackgroundColor.ToAndroid(), PorterDuff.Mode.Src);
flyoutContentRenderer.AndroidView.SetBackgroundDrawable(flyoutbackground);
}
return flyoutContentRenderer;
}
}
可以对Z1BDF6059919192CBDF8508204C4EBZ实施类似的类比,这是一个答案,可以帮助Z1B4419ABC4358B41D0CA507777A63908Z
相关问题: Shell TabBar 圆角,后面有视图
如果您使用Shell.FlyoutContent
或FlyoutContentTemplate
覆盖弹出内容,而不是基于 AppShell 层次结构的自动生成内容,请检查@FabriBertani 注释,因为您不需要自定义渲染器来实现这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.