xaml - ffimageloading:CachedImage 图像不适合网格
问题描述
关于如何让我的图像适合网格的任何建议?下面是我的代码。
<Grid HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ffimageloading:CachedImage
x:Name="mainImage"
Source="{Binding Image1}"
LoadingPlaceholder= "LoaderImage"
ErrorPlaceholder= "{Binding Image2}"
CacheDuration= "50"
RetryCount= "3"
RetryDelay= "600"
DownsampleToViewSize = "true"
Grid.Column="0"
WidthRequest="380"
HeightRequest="380"
Aspect="AspectFit">
<ffimageloading:CachedImage.Transformations>
<fftransformations:RoundedTransformation Radius="20"/>
</ffimageloading:CachedImage.Transformations>
</ffimageloading:CachedImage>
</Grid>
关于如何让我的图像适合网格的任何建议?
解决方案
问题是由 你设置WidthRequest="380"
的。HeightRequest="380"
图片的高度大于宽度。
因此,给出一个适当的 WidthRequest 和 HeightRequest 将解决如下问题:
WidthRequest="320"
HeightRequest="480"
更新:
<Grid HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ffimageloading:CachedImage BackgroundColor="Red"
x:Name="mainImage"
Source="logo.jpg"
CacheDuration= "50"
RetryCount= "3"
RetryDelay= "600"
DownsampleToViewSize = "true"
Grid.Column="0"
Aspect="AspectFit">
</ffimageloading:CachedImage>
</Grid>
推荐阅读
- java - ADB PULL 命令
- regex - 在 Spring 中匹配包含 .* 的正则表达式模式
- shell - CPUminer 配置文件错误
- ios - Watchkit - didReceiveApplicationContext 仅在第一次工作
- ckeditor4.x - CKEditor 自定义图片对话文字变化
- python - 在命令行中运行 python 脚本并向其发送参数
- python - BeautifulSoup...不一致的字段(可能存在或可能不存在)
- excel - 使用“if”函数来识别特定时间
- r - 如何相交并将分数添加到列?
- ios - 苹果对提交应用的新要求说必须支持 iPhone X 的 Super Retina 显示屏