【问题标题】:How do i make a fixed position button in a scrollable xaml如何在可滚动的 xaml 中制作固定位置按钮
【发布时间】:2020-06-16 22:17:29
【问题描述】:

我在 xaml 中有一个滚动视图,里面有一个网格,

<ScrollView>
    <Grid>
        //content
    </Grid>
</ScrollView>

我想在其中添加一个按钮,该按钮出现在屏幕的右下角,并且在我上下滚动时不会移动,类似于 html 中的从后到上固定按钮。

我试图将按钮放在滚动视图之外并将水平和垂直设置为“END”,但即使网格不需要滚动,它也会将它放在网格内容下方,我希望它始终位于右下角的屏幕上.

【问题讨论】:

  • 将您的网格添加到 StackLayout 并在 StackLayout 内的网格之后添加按钮。
  • 您需要一个有 2 行的网格。第 1 行将包含您的 ScrollView,第 2 行将包含您的按钮

标签: c# xaml xamarin position fixed


【解决方案1】:

Grid很容易实现:

<Grid Margin="20">

    <ScrollView VerticalOptions="FillAndExpand">
            <Label Text="FOR the most wild,d, yet most homely narrative which I am about to pen, I neither expect nor solicit belief. Mad indeed would I be to expect it, in ad, yet most homely narrative which I am about to pen, I neither expect nor solicit belief. Mad indeed would I be to expect it, in ad, yet most homely narrative which I am about to pen, I neither expect nor solicit belief. Mad indeed would I be to expect it, in ad, yet most homely narrative which I am about to pen, I neither expect nor solicit belief. Mad indeed would I be to expect it, in ad, yet most homely narrative which I am about to pen, I neither expect nor solicit belief. Mad indeed would I be to expect it, in a yet most homely narrative which I am about to pen, I neither expect nor solicit belief. Mad indeed would I be to expect it, in a case where my very senses reject their own evidence. Yet, mad am I not -- and very surely do I not dream. But to-morrow I die, and to-day I would unburthen my soul. My immediate purpose is to place before the world, plainly, succinctly, and without comment, a series of mere household events. In their consequences, these events have terrified -- have tortured -- have destroyed me. Yet I will not attempt to expound them. To me, they have presented little but Horror -- to many they will seem less terrible than barroques. Hereafter, perhaps, some intellect may be found which will reduce my phantasm to the common-place -- some intellect more calm, more logical, and far less excitable than my own, which will perceive, in the circumstances I detail with awe, nothing more than an ordinary succession of very natural causes and effects." />
    </ScrollView>

    <Button BackgroundColor="Red" Text="Press Me" HorizontalOptions="End" VerticalOptions="End"/>

</Grid>

结果如下:

【讨论】:

    猜你喜欢
    • 2019-08-18
    • 2016-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多