Why do I get different colours from same code in Android 4 /5 and Android 7 RRS feed

  • Question

  • User262631 posted


    I am working on an Xamarin.Android App originally developed by another company.

    I created "active" buttons - different colours when Pressed/Unpressed and Disabled.

    The button is defined as an axml in "drawable" and is included in a Button via: android:background="@drawable/EnhancedButton"

    There are a number of different coloured buttons which all work exactly as intended on Android 4 and 5 systems. However, In Android 7.1 the colours have no resemblance to the requested ones. The buttons are defined as - However, changing these to just plain Button does not fix the issue. I cannot see anything in either the axml files implementing the Buttons nor the backing code (C#) that would cause this difference. There is an AppTheme declared in styles - but I cannot see anything there that should cause an issue.

    This is correct (as shown in Android 4 & 5):

    The same buttons in Android 7 - colours totally wrong.

    Can anyone suggest why Android 7 (and maybe 6) should mess with the colours like this - or there's anything changed or some colour control item that could cause this effect. Spent a few days trying to get to the bottom of this and still can't find the issue...

    Many thanks!

    Tuesday, August 1, 2017 3:36 PM


  • User262631 posted

    Found it: <item name="android:buttonStyle"> @style/ColoredButton </item>

    buttonStyle set to an internal button style with BackgroundTint and BackgroundTintMode set to values seems to over-ride defined colours for the buttons in Android v7 but not in 4 or 5. Removal of this line fixes the issue.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, August 2, 2017 1:56 PM