我对Xamarin Forms很新,我试图将XAML页面拆分为顶部“行”的背景图像和底部“行”的白色背景。
灰色背景代表我当前拥有的背景图片,它位于ContentPage标记中。在这种情况下,白色背景没有达到屏幕的整个宽度(因为它在ContentPage的Grid.Row内)既不是屏幕的底部。 如果我只是在网格的第一行添加背景图像,页面标题(Iniciar Sesion)将没有背景图像。
我只需要将整个ContentPage拆分为2行,一行包含背景图像,另一行不包含背景图像。 我真的需要在XAML中完成它,而不是在C#中。
有什么想法吗?
提前致谢!
答案 0 :(得分:0)
您可以使用相对布局轻松实现您的请求(单击here以了解Xamarin文档中的相对布局):
<?xml version="1.0" encoding="utf-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="YourNamesapce.YourPage">
<RelativeLayout>
<Image
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Width,Factor=1}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Height,Factor=0.5}"
Source="icon.png"
Aspect="AspectFill"/>
<Grid
RelativeLayout.WidthConstraint="{ConstraintExpression
Type=RelativeToParent,Property=Width,Factor=1}"
RelativeLayout.HeightConstraint="{ConstraintExpression
Type=RelativeToParent,Property=Height,Factor=1}">
<!-- Your Grid Layout-->
</Grid>
</RelativeLayout>
默认情况下,背景页面颜色为白色,因此可以使用,否则将页面的背景颜色属性设置为您想要的颜色。