Note: I originally posted this a couple days ago, but it got closed due to insufficient/unclear detail. Hopefully this repost passes muster
I'm creating an Android/iOS app using Xamarin.Forms.
I've found that selected RadioButtons render in red on Android:
I want to use a different color that's in my app's theme.
I found a Xamarin forum post which described the standard mechanism for this, which is to implement a custom renderer by adding the following code in the Android project:
[assembly: ExportRenderer(typeof(Xamarin.Forms.RadioButton), typeof(MyRenderer))]
namespace MyApp.Droid
{
public class MyRenderer : RadioButtonRenderer
{
public MyRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Button> e)
{
base.OnElementChanged(e);
if(Control != null)
{
Control.ButtonTintList = ColorStateList.ValueOf(Android.Graphics.Color.Yellow);
}
}
}
}
I've added the code (renderer is in my Android project); it compiles, runs (on Android), the button appears & functions, etc.
However, neither MyRenderer() nor OnElementChanged() is ever called.
Is there something additional needed to cause the app to use the custom renderer?
Thanks!