官網說明為
- 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 完全看不出哪裡有差異,>.<
沒有留言:
張貼留言