Created
March 6, 2015 19:59
-
-
Save kjeremy/d1f6fd52bdf693a738f4 to your computer and use it in GitHub Desktop.
MvxTintSpinner for AppCompat v21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Then in your AppCompatViewFactory from kjeremy/gist:5b76cb2eb82ff6caa046