【问题标题】:XAML add logo to Xamarin Crossplatform formXAML 将徽标添加到 Xamarin 跨平台表单
【发布时间】:2020-02-28 11:15:22
【问题描述】:

如何将徽标添加到 Xaml 表单的中心,我开始使用 Xamarin。

我的 xaml 代码如下所示:

    <StackLayout Spacing="20" Padding="50" VerticalOptions="Center">  
        <Entry Placeholder="Mail id"></Entry>  
        <Entry Placeholder="Password" IsPassword="True"></Entry>  
        <Button Text="Log In" TextColor="White" BackgroundColor="##ff77D065"></Button> </StackLayout>  
</ContentPage>

这很好用,现在我想看看在哪里可以将徽标添加到 Xaml 表单,它的跨平台。

我是新手。

编辑

尝试这样的事情

<StackLayout Spacing="20" Padding="50" VerticalOptions="Center">
             VerticalOptions="Center" Padding="10">
    <Image Source="screenimg2.png" x:Name="imgLogo" HeightRequest="150" WidthRequest="150"/>  
    <Entry Placeholder="Mail id"></Entry>  
    <Entry Placeholder="Password" IsPassword="True"></Entry>  
    <Button Text="Log In" TextColor="White" BackgroundColor="##ff77D065"></Button> 
</StackLayout>  

【问题讨论】:

  • 看看这个thread
  • 使用Image控件
  • @Jason ,你的意思是在 Edits 上是这样的吗?请看编辑?
  • @Sam 您是否试图将Image 居中,而不是将所有其他控件覆盖在页面居中图像的顶部?
  • @SushiHangover,是的

标签: c# xaml xamarin


【解决方案1】:

您可以使用AbsoluteLayout 来包含您的“背景”徽标,然后是StackLayout,两者都位于屏幕中心,然后将您的 UI 小部件放置在 StackLayout 内以控制它们的放置顺序:

示例(徽标设置为 25% 的不透明度):

<AbsoluteLayout BackgroundColor="Black">
    <Image Source="logo.png" AbsoluteLayout.LayoutBounds=".5,.5,.75,.75" AbsoluteLayout.LayoutFlags="All" Opacity=".25" />
    <StackLayout AbsoluteLayout.LayoutBounds="1,1,1,1" AbsoluteLayout.LayoutFlags="All" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"  >
        <Label Text="INTRO TO THE WORLD" TextColor="Green" />
        <Entry Text="Some Entry Text" BackgroundColor="Green" />
    </StackLayout>
</AbsoluteLayout>

回复:Xamarin.Forms AbsoluteLayout

【讨论】:

    猜你喜欢
    • 2017-02-16
    • 2015-10-20
    • 2017-08-20
    • 2020-08-12
    • 1970-01-01
    • 1970-01-01
    • 2018-10-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多