【问题标题】:Is there a way to get my BackgroundImage to fill the ContentPage evenly? Xamarin.Forms, XAML有没有办法让我的 BackgroundImage 均匀地填充 ContentPage? Xamarin.Forms,XAML
【发布时间】:2017-03-07 15:34:10
【问题描述】:

这是我当前的代码。

<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:Quickies" x:Class="Quickies.QuickiesPage" BackgroundImage="Overview Image.png">
</ContentPage>

我可以在 XAML 中设置一个属性来使图像均匀地填充页面吗?现在是截止时间:

[

【问题讨论】:

    标签: xaml xamarin xamarin.forms


    【解决方案1】:

    试试这个可能对你有帮助。

    <?xml version="1.0" encoding="utf-8"?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:Quickies" x:Class="Quickies.QuickiesPage">
    <Grid Padding="0">
        <Image
            Aspect="AspectFill"
            Source="Overview Image.png"
            RelativeLayout.WidthConstraint= "{ConstraintExpression Type=RelativeToParent, Property=Width}"
            RelativeLayout.HeightConstraint= "{ConstraintExpression Type=RelativeToParent, Property=Height}">
        </Image>
    </Grid>
    </ContentPage>
    

    【讨论】:

    • 是的,我能够使用相同的代码实现我想要的。我只是想知道是否有办法通过其他属性实现它。我开始认为没有。
    • @msloan11 我已经搜索了其他解决方案,但最终得到了这个。
    猜你喜欢
    • 2021-08-03
    • 1970-01-01
    • 2021-05-14
    • 2015-02-24
    • 2015-11-19
    • 1970-01-01
    • 2021-12-27
    • 1970-01-01
    相关资源
    最近更新 更多