Forum Xamarin.Forms

Disabled-look on Android Button Images

sonic1015sonic1015 CAMember ✭✭

Looking to auto-magically make the button images look disabled on Android with a custom renderer. On iOS, this was simple enough:

[assembly: ExportRenderer(typeof(Button), typeof(CustomButtonRenderer))]
namespace AppName.iOS.Renderers
    public class CustomButtonRenderer : ButtonRenderer
        protected override void OnElementChanged(ElementChangedEventArgs<Button> e)

            if (Control == null) return;

            Control.AdjustsImageWhenDisabled = true;

But I failed to replicate this effect for Android. Is there a way?


  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Looking to auto-magically make the button images look disabled on Android with a custom renderer.

    What's wrong with actually disabling them at the shared layer? Why would you want enabled buttons to look disabled?

  • sonic1015sonic1015 CAMember ✭✭

    I'll clarify: look disabled when disabled.

    With the custom renderer for iOS above, the images in the buttons go gray when disabled.

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Ok... Let me fill in the blank that I think you're implying but not saying..
    Problem: Disabled buttons don't look disabled.

    Is that what you're getting at? That your disabled buttons don't look disabled? I'm just guessing here. Screen shots would help a lot.

  • sonic1015sonic1015 CAMember ✭✭

    Fair enough. First shot the six buttons should look disabled, and the second shot, the buttons are enabled (match with the lock button). When there's just text, it's fine but with images, they don't look disabled. It was the same thing on iOS until I made that simple renderer (don't have a device handy for a screenshot).

    Understandably, I could set up a trigger event to change the image when the button is disabled, but if there's a simple solution for Android as there was for iOS, I would prefer that.

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Ah... Ok. This is specific to ButtonImage - I missed that even though you said that. Sorry. I never use the thing because of all the problems they have.
    This one is already documented as an issue.

    So you may or may not even be able to band-aid it through a renderer if the problem runs deep.

    Which means you're just looking to hack around it at this point.
    A fast agnostic fix would be to put a panel over it of a mostly transparent white that is only visible when the button is disabled. (Bind IsVisible to the button's IsEnabled through a BoolInvertConverter) Then the blocking semi-transparent panel will give the entire control that frosted/greyed-out look.

  • sonic1015sonic1015 CAMember ✭✭
    edited August 2018

    I guess I'm looking for hack, but a native level hack if anyone knows of one.

Sign In or Register to comment.