我知道,ListView类没有名为BackgroundImage
的属性 - 只有BackgroundColor
属性,但这不是我正在寻找的属性。有没有办法将一个背景图像添加到ListView中,以便当我滚动图像时保持原位,并且在滚动时,图块只是“移动”图像。如何将BackgroundImage添加到Xamarin Forms中的ListView中?
将图像添加到ContentPage
也不起作用,因为ListView只是覆盖它。
我知道,ListView类没有名为BackgroundImage
的属性 - 只有BackgroundColor
属性,但这不是我正在寻找的属性。有没有办法将一个背景图像添加到ListView中,以便当我滚动图像时保持原位,并且在滚动时,图块只是“移动”图像。如何将BackgroundImage添加到Xamarin Forms中的ListView中?
将图像添加到ContentPage
也不起作用,因为ListView只是覆盖它。
设置你的ListView
的BackgroundColor
到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>
这工作,但它弄乱了我的ListView滚动。 –
@LeMotJuiced设置背景色应该对ListView滚动没有影响,你应该在你的问题和代码中发布一个新问题 – SushiHangover
它不设置背景颜色,它将一个ListView放在RelativeLayout中。 –
你可以尝试做透明的列表视图和列表视图项的背景和在图片列表视图后面。 – gbishop3