Created
November 16, 2016 16:57
-
-
Save ChaseFlorell/7124807d8e1aa69a47159b0653da1102 to your computer and use it in GitHub Desktop.
Xamarin Forms Android Ripple Effect
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
public class TouchableBoxViewRenderer_Droid : BoxRenderer | |
{ | |
protected override void OnElementChanged(ElementChangedEventArgs<BoxView> e) | |
{ | |
base.OnElementChanged(e); | |
if (e.NewElement == null) return; | |
var attrs = new[] {Android.Resource.Attribute.SelectableItemBackground}; | |
var ta = Context.ObtainStyledAttributes(attrs); | |
var drawableFromTheme = ta.GetDrawable(0); | |
drawableFromTheme.SetTint(Element.Color.ToAndroid()); | |
ta.Recycle(); | |
Foreground = drawableFromTheme; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment