如何消除Xamarin.Forms中的listview涟漪效应
我有一个带有列表视图的Xamarin.Forms应用程序。 当按下列表项时,在Android上会产生连锁反应。抑制这种波动是一项要求 我在Android项目中尝试过一种风格:如何消除Xamarin.Forms中的listview涟漪效应,xamarin.forms,Xamarin.forms,我有一个带有列表视图的Xamarin.Forms应用程序。 当按下列表项时,在Android上会产生连锁反应。抑制这种波动是一项要求 我在Android项目中尝试过一种风格: <style name="MainTheme" parent="MainTheme.Base"> <item name="android:listViewStyle">@style/ListViewStyle.Light</item> </style> &l
<style name="MainTheme" parent="MainTheme.Base">
<item name="android:listViewStyle">@style/ListViewStyle.Light</item>
</style>
<style name="ListViewStyle.Light" parent="android:style/Widget.ListView">
<item name="android:listSelector">@drawable/actionbar_background_green</item>
</style>
那也没用。涟漪效果仍然存在,只有当涟漪结束时,选定的项目才会选择新的背景色
这个问题涉及到Xamarin.Forms,而不是Xamarin.Android或Java。这是一个老问题,但我希望这个答案能帮助其他人寻找解决方案。您可以将一个完全填充它的
框架
添加到您的查看单元格
,并向该框架添加一个空的点击手势识别器。这样ViewCell就不会检测到任何点击,因此不会触发涟漪效应
布局示例:
<ListView ItemsSource="{Binding ItemsSource}" HasUnevenRows="True" SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<AbsoluteLayout>
<Frame AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,1" BackgroundColor="Transparent">
<Frame.GestureRecognizers>
<TapGestureRecognizer/>
</Frame.GestureRecognizers>
</Frame>
<!-- Your controls !-->
</AbsoluteLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
什么叫涟漪效应?请看这里:尝试使用背景。看看这里为什么不添加代码示例?如果您添加一个代码示例,对于其他人来说,更容易理解问题。@SwissCodeMen我已经添加了示例。
<ListView ItemsSource="{Binding ItemsSource}" HasUnevenRows="True" SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<AbsoluteLayout>
<Frame AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,1" BackgroundColor="Transparent">
<Frame.GestureRecognizers>
<TapGestureRecognizer/>
</Frame.GestureRecognizers>
</Frame>
<!-- Your controls !-->
</AbsoluteLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>