官網說明為
- Fill - Stretches the image to completely and exactly fill the display area. This may result in the image being distorted.
- AspectFill - Clips the image so that it fills the display area while preserving the aspect (ie. no distortion).
- AspectFit - Letterboxes the image (if required) so that the entire image fits into the display area, with blank space added to the top/bottom or sides depending on the whether the image is wide or tall.
MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App1"
x:Class="App1.MainPage">
<StackLayout>
<Image
Source="Firework.jpg"
HeightRequest="200"
Aspect="AspectFit">
</Image>
</StackLayout>
</ContentPage>
Firework.jpg 位置呈現效果為
- 原圖
- Fill
- AspectFill
- AspectFit
沒有故意設定 Image 高度,AspectFill 和 AspectFit 完全看不出哪裡有差異,>.<
![[X.Form] Image](https://farm5.staticflickr.com/4069/35712655946_a3d21cff80.jpg)

![[X.Form] Image - Aspect 屬性 - Fill](https://farm5.staticflickr.com/4060/34943150973_ff2a156e98.jpg)
![[X.Form] Image - Aspect 屬性 - AspectFill](https://farm5.staticflickr.com/4121/35583622482_905a29d64c.jpg)
![[X.Form] Image - Aspect 屬性 - AspectFit](https://farm5.staticflickr.com/4143/34911641484_9eaa150203.jpg)
沒有留言:
張貼留言