如何设置ScrollView内容的大小? [英] how do I SET the size of the ScrollView content?

查看:916
本文介绍了如何设置ScrollView内容的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在ScrollView ContentSize属性为只读,我该如何设置 ScrollView内容的大小? 与UIScrollView中可设置的属性完全相同 (但不是xamarin形式)

Now that ScrollView ContentSize property is readonly how do I SET the size of the ScrollView content? That very same property that is settable in UIScrollView (but not in xamarin forms)

我有这个:

  <ScrollView Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" HorizontalOptions="FillAndExpand"
              x:Name="attachmentScroller"
              >
    <StackLayout x:Name="AttachmentsView" Orientation="Horizontal" VerticalOptions="Fill"/>
  </ScrollView>

我尝试过的是将AttachmentsView.MinimumWidthRequest设置为所需的contentWidth; 但这似乎并没有扩大父级的scrollview内容的宽度 达到所需的值.

what I've tried is setting AttachmentsView.MinimumWidthRequest to the desired contentWidth; But that does not seem to expand the parent's scrollview content width to the desired value.

推荐答案

您可以通过设置内容的属性(而不是ScrollView)来设置内容大小的设置.

You can set the set of the content size, by setting the property of the content, instead of the the ScrollView.

这里是xaml

<ScrollView>
    <StackLayout HeightRequest="100" />
</ScrollView>

这篇关于如何设置ScrollView内容的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆