Xamarin.Forms ListView中具有裁剪高度的全宽图像

时间:2016-11-11 19:53:58

标签: c# xaml xamarin xamarin.forms

我正在加载一个项目列表,我试图将图像(来自URL)布局为全宽背景,必要时裁剪高度,并覆盖一些文本和图像最佳。无论我做什么,我都无法将图像扩展到全宽和高度。我已经尝试过我能想到的一切,但是这里的代码看起来是这样的:

<StackLayout x:Name="mainStack" Orientation="Vertical">
  <Label x:Name="errorMsg" IsVisible="False" />
  <ActivityIndicator IsRunning="False" IsVisible="False" x:Name="activityIndicator" />
  <ListView CachingStrategy="RecycleElement" IsPullToRefreshEnabled="true" Refreshing="OnRefreshItems" ItemSelected="LoadDetails" HorizontalOptions="CenterAndExpand" Margin="20" RowHeight="280">
    <ListView.ItemTemplate>
      <DataTemplate>
        <ViewCell>
          <StackLayout Spacing="0" HorizontalOptions="FillAndExpand">
            <AbsoluteLayout HeightRequest="200" HorizontalOptions="FillAndExpand">
              <Image Aspect="AspectFill" Source="{Binding ImageUrl}" HorizontalOptions="FillAndExpand" HeightRequest="200" />
              <Image Aspect="AspectFill" HorizontalOptions="FillAndExpand" Source="opacity.png" />
              <Image Source="favorite.png" HeightRequest="50" />
              <StackLayout Orientation="Horizontal" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="1,0,.3,.3" >
                <Image Source="shareList.png" HeightRequest="30" />
                <Image Source="shareList.png" HeightRequest="30" />
              </StackLayout>
              <StackLayout Orientation="Vertical" VerticalOptions="EndAndExpand" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds=".1,.7,.8,.1">
                <Label Text="{Binding StartFormatted}"  TextColor="#ffffff" Style="{StaticResource dateList}" />
                <Label Text="{Binding Name}" TextColor="#ffffff" Style="{StaticResource h1Style}" />
              </StackLayout>
            </AbsoluteLayout>

0 个答案:

没有答案