Disable listview animation on selected

How can I disable the animation of listviews/cellview when they are clicked on. The animation is fine on Android, but on iOS, when the listview item is selected, there is a grey background as well as lines that animate and don't look good at all. I have fixed the grey background by creating a custom renderer for iOS, but cannot figure out how to remove the animation of lines when an item is clicked.

Answers

  • AndreiMisiukevich_AndreiMisiukevich_ USMember ✭✭✭✭

    You can add TapGestureRecognizer to your view) it will prevent animations

  • alkhamisahalkhamisah Member ✭✭

    @AndreiMisiukevich_ Can you please elaborate on which view to add the TapRecognizer and which command to associate it with? since we still need the list to be clickable.Should we add it to the ViewCell? and how it will affect the performance if we create new gesture recognizer for each item in the list?

  • BasuBasu USMember ✭✭

    @SteveRussell said:
    How can I disable the animation of listviews/cellview when they are clicked on. The animation is fine on Android, but on iOS, when the listview item is selected, there is a grey background as well as lines that animate and don't look good at all. I have fixed the grey background by creating a custom renderer for iOS, but cannot figure out how to remove the animation of lines when an item is clicked.

    Use the below custom renderer for iOS:

    public class ListViewDisablecolorRenderer: ListViewRenderer
    {
    protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
    {
    base.OnElementPropertyChanged(sender, e);

            if (Control == null)
            {
                return;
            }
    
            if (e.PropertyName == "SelectedItem")
            {
                foreach (var cell in Control.VisibleCells)
                {
                    cell.SelectionStyle = UITableViewCellSelectionStyle.None;
                }
            }
        }
    
    }
    
  • alkhamisahalkhamisah Member ✭✭

    I added the TapGestureRecognizer to the viewcell and removed ItemTappedCommand from the listview, but i am still getting the animation on iOS

  • BasuBasu USMember ✭✭

    @alkhamisah said:
    I added the TapGestureRecognizer to the viewcell and removed ItemTappedCommand from the listview, but i am still getting the animation on iOS

    Tap gesture is not required for listveiw, just add item select event for listview and add the custom renderer for iOS.

Sign In or Register to comment.