Skip to content

Instantly share code, notes, and snippets.

@kjeremy
Created March 6, 2015 19:59
Show Gist options
  • Save kjeremy/d1f6fd52bdf693a738f4 to your computer and use it in GitHub Desktop.
Save kjeremy/d1f6fd52bdf693a738f4 to your computer and use it in GitHub Desktop.
MvxTintSpinner for AppCompat v21
/// <summary>
/// Tint-aware version of MvxSpinner so that it's styled properly
/// with AppCompat V21
/// </summary>
public class MvxTintSpinner : MvxSpinner
{
private static readonly int[] TintAttrs =
{
Android.Resource.Attribute.Background,
Android.Resource.Attribute.PopupBackground
};
public MvxTintSpinner(Context context, IAttributeSet attributes)
: base(context, attributes)
{
TintTypedArray a = TintTypedArray.ObtainStyledAttributes(
context, attributes, TintAttrs, Android.Resource.Attribute.SpinnerStyle, 0);
SetBackgroundDrawable(a.GetDrawable(0));
if ((int)Build.VERSION.SdkInt >= 16 && a.HasValue(1))
SetPopupBackgroundDrawable(a.GetDrawable(1));
a.Recycle();
}
}
@kjeremy
Copy link
Author

kjeremy commented Mar 6, 2015

Then in your AppCompatViewFactory from kjeremy/gist:5b76cb2eb82ff6caa046

case "MvxSpinner":
    return new MvxTintSpinner(context, attrs);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment