如何在Xamarin Forms中向ListView添加背景图像?

问题描述 投票:4回答:1

我知道ListView类没有名为BackgroundImage的属性 - 只有BackgroundColor属性,但这不是我想要的。有没有办法将背景图像添加到ListView,以便当我滚动图像时保持原位,并且在滚动时图块只是“移动”在图像上。

将图像添加到ContentPage也不起作用,因为ListView只是覆盖它。

c# xaml xamarin xamarin.forms background-image
1个回答
4
投票

你的帖子非常好,你只是错过了Source属性上的双引号

将你的ListViewBackgroundColor设置为Transparent

<RelativeLayout>
    <Image Source="background.png" 
        BackgroundColor="Transparent" 
        VerticalOptions="CenterAndExpand" 
        HorizontalOptions="CenterAndExpand"/>
    <ListView x:Name="listView" 
        VerticalOptions="CenterAndExpand"
        HorizontalOptions="CenterAndExpand"
        BackgroundColor="Transparent"
              ItemTapped="OnItemTapped"
              ItemsSource="{Binding .}" />
</RelativeLayout>
© www.soinside.com 2019 - 2024. All rights reserved.