Skip to content

Instantly share code, notes, and snippets.

@ChaseFlorell
Created November 16, 2016 16:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChaseFlorell/7124807d8e1aa69a47159b0653da1102 to your computer and use it in GitHub Desktop.
Save ChaseFlorell/7124807d8e1aa69a47159b0653da1102 to your computer and use it in GitHub Desktop.
Xamarin Forms Android Ripple Effect
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