2017-06-13 42 views
4

我知道,ListView类没有名为BackgroundImage的属性 - 只有BackgroundColor属性,但这不是我正在寻找的属性。有没有办法将一个背景图像添加到ListView中,以便当我滚动图像时保持原位,并且在滚动时,图块只是“移动”图像。如何将BackgroundImage添加到Xamarin Forms中的ListView中?

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

+0

你可以尝试做透明的列表视图和列表视图项的背景和在图片列表视图后面。 – gbishop3

回答

4

设置你的ListViewBackgroundColorTransparent

<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> 
+0

这工作,但它弄乱了我的ListView滚动。 –

+0

@LeMotJuiced设置背景色应该对ListView滚动没有影响,你应该在你的问题和代码中发布一个新问题 – SushiHangover

+0

它不设置背景颜色,它将一个ListView放在RelativeLayout中。 –

相关问题