【问题标题】:StackLayout transparent colorStackLayout 透明色
【发布时间】:2020-03-26 04:36:01
【问题描述】:

我需要一些帮助,我想在 UI 底部的固定位置设置一个按钮,如何使用 Xamarin.Forms 执行此操作?我也想在 StackLayout 上设置透明颜色,但没有运气。

<ScrollView>
    <StackLayout>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
        <Label Text="fds"/>
    </StackLayout>
</ScrollView>
<StackLayout BackgroundColor="LightBlue" Opacity="0.3" Orientation="Horizontal" VerticalOptions="End">
    <Button CornerRadius="30" HorizontalOptions="CenterAndExpand"  VerticalOptions="CenterAndExpand"/>
</StackLayout>

在预览器中 Image 它是透明的。 在电话上 Image

【问题讨论】:

  • 你的两张图片和我一模一样。如果您希望您的 StackLayout 是透明的,为什么颜色设置为“LightBlue”?
  • @Jason No see first again 文本出现在 StackLayout 后面
  • 第一张图片似乎有不自然的行为。 @Jason 底部StackLayout 中的Opacity 属性使ScrollView 中的标签可见是否正常?
  • 您的要求是什么?在底部放一个按钮?

标签: xaml xamarin.forms


【解决方案1】:

如果您想在 UI 底部放置一个按钮,请使用网格

    <Grid Margin="10" >

        <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

        <StackLayout Grid.Row="0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
        <ScrollView>
            <StackLayout>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
                <Label Text="fds"/>
            </StackLayout>
        </ScrollView>


    </StackLayout>

        <StackLayout Grid.Row="0" BackgroundColor="Transparent" HorizontalOptions="FillAndExpand" VerticalOptions="End">
        <Button CornerRadius="25" VerticalOptions="End" Margin="5,0,5,0" Text="Your Button" FontSize="Small" TextColor="White" BackgroundColor="#40db7093"></Button>
        </StackLayout>

    </Grid>

您可以在第一个 stacklayout 中放置任何控件。

【讨论】:

  • 是的,但是滚动视图呢?
  • 是的,您可以在网格外添加滚动视图
  • 或者你可以在第一个stacklayout中使用listview,即; Grid.Row 0
  • 我不明白..你需要什么例子?
  • 我不知道为什么我失去了透明颜色,但是当我添加滚动视图时,我在按钮上得到了白色背景
猜你喜欢
  • 1970-01-01
  • 2019-11-29
  • 2011-03-02
  • 2013-11-30
  • 1970-01-01
  • 1970-01-01
  • 2020-11-29
  • 2017-06-04
  • 2014-03-22
相关资源
最近更新 更多