Forum Xamarin.Forms

Xamarin forms ListView LongTape color.

manul74manul74 Member ✭✭

Hello.

I have a ListView with its own coloring. When I do a long press I lose color. How to set the color I want with a long press. I cannot find the setting of these colors

Thank you.

My XAML

<?xml version="1.0" encoding="utf-8" ?>

    <ListView x:Name="lst1" SeparatorVisibility="None">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <ViewCell.ContextActions>
                        <MenuItem Text="MENU1" />
                        <MenuItem Text="MENU2" />
                    </ViewCell.ContextActions>
                    <StackLayout>
                        <Label TextColor="White"  Text="{Binding name1}" />
                    </StackLayout>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
 </StackLayout>

result

Posts

  • manul74manul74 Member ✭✭

    Problem solved

    Add in style.xml

      <item name="android:colorPressedHighlight">@color/ListViewSelected</item>
      <item name="android:colorLongPressedHighlight">@color/ListViewHighlighted</item>
      <item name="android:colorFocusedHighlight">@color/ListViewSelected</item>
      <item name="android:colorActivatedHighlight">@android:color/transparent</item>
      <item name="android:activatedBackgroundIndicator">@color/ListViewSelected</item>
    

    add to colors.xml

    <?xml version="1.0" encoding="utf-8"?>

    <color[] name="launcher_background">#FFFFFF
    <color[] name="colorPrimary">#3F51B5
    <color[] name="colorPrimaryDark">#303F9F
    <color[] name="colorAccent">#FF4081
    <color[] name="ListViewSelected">#629460
    <color[] name="ListViewHighlighted">#629460

    remove []

Sign In or Register to comment.