Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Android Highlight and Background Color of a Cell

$
0
0

So I'm trying to theme the background color of a cell. And keep a long press highlight on the item.

I've themed the highlight with the style.xml:

<style name="MyTheme" parent="MyTheme.Base">
<style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <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">@color/ListViewSelected</item>
    <item name="android:activatedBackgroundIndicator">@color/ListViewSelected</item>
</style>
<color name="ListViewSelected">#96BCE3</color>
<color name="ListViewHighlighted">#4BA398</color>

Which gives this output:

I have coloured the add cell white below with the following code:

public class AddCellRenderer : ViewCellRenderer
{
    protected override Android.Views.View GetCellCore(Xamarin.Forms.Cell item, Android.Views.View convertView, Android.Views.ViewGroup parent, Android.Content.Context context)
    {
        var result = base.GetCellCore(item, convertView, parent, context);
        result.SetBackgroundColor(Android.Graphics.Color.White);
        return result;
    }
}

When I color the cell above via the same code, it works but the highlight color must be behind it, as then it doesn't show.

Does anyone know how do I get background color of a cell working with a long press highlight color on Android?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>