如何将 BackgroundImage 添加到 Xamarin Forms 中的 ListView?

Lou*_*upi 5 c# xaml background-image xamarin xamarin.forms

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

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

Sus*_*ver 4

你的帖子真的很好,你只是错过了源属性上的双引号

将您的ListView设置BackgroundColorTransparent

<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>
Run Code Online (Sandbox Code Playgroud)