【问题标题】:Xamarin Forms Image Sizing in iOSXamarin 在 iOS 中形成图像大小
【发布时间】:2019-05-05 15:43:11
【问题描述】:

我在调整 iOS 设备中的图像大小时遇到​​了困难。我在 iOS 项目的 Resource 文件夹中放置了 3 张图片(forest.png、forest@2x、forest@3x)。使用不同的 iOS 设备,图像以相同的大小显示

<Image Aspect="AspectFit" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" Source="forest"/>

我做错了什么,或者需要修改什么? 提前致谢

【问题讨论】:

  • 尝试不使用 Aspect="AspectFit",因为它可以提供相似的尺寸并适合
  • 试过了,没有变化:(
  • @mohammadanouti - 你检查了所有三个图像的分辨率吗?
  • 我用资源文件中每个图像的尺寸编辑了问题
  • 尝试将它们放入图像断言中。

标签: ios xamarin.forms image-size


【解决方案1】:

这应该是预期的行为,因为screen resolution/image size 比率将相同。

如果您想在所有屏幕上放置具有相同百分比面积的图像,请使用AbsoulteLayoutGrid 放置。

(放置一个使用 60% 屏幕的图像):

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="3*"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="3*"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>

    <Image Grid.Row="1" Grid.Column="1" Source="Forest" Acpect="AspectFit"/>
</Grid>

【讨论】:

    猜你喜欢
    • 2016-08-28
    • 2017-05-07
    • 1970-01-01
    • 2016-02-28
    • 1970-01-01
    • 2018-12-27
    • 1970-01-01
    • 2018-09-22
    • 1970-01-01
    相关资源
    最近更新 更多