I would like to change the transparency level of disabled button.
Disabled Button View
Enabled Button View
[assembly: ExportRenderer(typeof(LabelButton), typeof(SkyRacing.Droid.LabelButtonRenderer))]
namespace SkyRacing.Droid
{
public class LabelButtonRenderer : MaterialButtonRenderer
{
public LabelButtonRenderer(Context ctx) : base(ctx)
{
}
protected override void OnDraw(Android.Graphics.Canvas canvas)
{
base.OnDraw(canvas);
if (!Element.IsEnabled)
Element.Opacity = 0.9;
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == nameof(Xamarin.Forms.Button.IsEnabled))
{
if (!Element.IsEnabled)
Element.Opacity = 0.9;
}
}
}
}
I've tried creating a custom renderer and changing the opacity of the disabled button to 0.9 but still it is too transparent. How can reduce the transparency level of the button? (fyi, on debug mode I've inspected the Element property. It is already 1 even before I set to 0.9, wonder how it is too much transparent).


You can customize any property if
Buttonwhen it isdisabledby usingStyle. Change the value ofOpacityto change transparency level of the button.Update code:
And add color in the colors.xml:
Update iOS code: