xaml - xamarin 形式的背景
问题描述
我想为弹出窗口创建背景。
背景是指半透明背景,位于弹出窗口后面并在整个应用程序屏幕上延伸。这使得弹出窗口更加占主导地位,并阻止点击背景中其他任何内容的可能性。
如果可能的话,如果弹出窗口 xaml 代码位于视图结构的深处,那将是最好的。不在层次结构的顶部或底部。
我的问题是背景尺寸不会超过其父尺寸。
因此,如果我的视图是 1000x1000 我的视图内容是 500x500 并且我的弹出窗口在这个 500x500 中,它不会超过这个大小。
我尝试使用 Position absolute、relative、translatin x/y,将边距调整为高值以获得更大的尺寸。
我只是无法完成它。
解决方案
您可以使用 Plugin PopupPage。并根据需要设置弹出窗口的布局
<?xml version="1.0" encoding="utf-8" ?>
<pages:PopupPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
x:Class="MyProject.MyPopupPage">
<!--You can set an animation in the xaml file or in the csharp code behind-->
<pages:PopupPage.Animation>
<animations:ScaleAnimation
PositionIn="Center"
PositionOut="Center"
ScaleIn="1.2"
ScaleOut="0.8"
DurationIn="400"
DurationOut="300"
EasingIn="SinOut"
EasingOut="SinIn"
HasBackgroundAnimation="True"/>
</pages:PopupPage.Animation>
<!--You can use any elements here which are extended from Xamarin.Forms.View-->
<StackLayout
VerticalOptions="Center"
HorizontalOptions="Center"
Padding="20, 20, 20, 20">
//...
</StackLayout>
</pages:PopupPage>
有关更多详细信息,您可以查看https://github.com/rotorgames/Rg.Plugins.Popup/wiki/Getting-started
推荐阅读
- c++ - 没有名为“argument_type”的类型
- elasticsearch - Kibana(elasticsearch 可视化) - 如何根据字段的子字符串添加绘图?
- c# - C#.net 如何完全忽略/消除 datetimepicker 中的日期值?
- rest - 从 Spring Boot RestController 返回 Clojure PersistentVector
- android - 如何取消 android studio 更新
- reactjs - React + Axios - 加载的数据能够控制台日志但未显示在 DOM 中?
- javascript - 在 taffydb 中搜索多个词
- php - 通过 cli 运行 php 脚本不会使用 lsof 将文件显示为打开
- c++ - 如何将 char 添加到 istringstream?
- html - 如何在没有 JS 的情况下将“number-parent”类 div 的高度设置为等于“active-lg”类 div