private static void SetOverlay(BindableView view, CompositeDisposable disposables, Drawable overlay) { #if __ANDROID_18__ if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Kitkat) { ExecuteWithNoRelayout(view, v => v.Overlay.Add(overlay)); disposables.Add(() => ExecuteWithNoRelayout(view, v => v.Overlay.Remove(overlay))); } else #endif { // Set overlay is not supported by this platform, set the background instead // and merge with the existing background. // It'll break some scenarios, like having borders on top of the content. var list = new List <Drawable>(); var currentBackground = view.Background; if (currentBackground != null) { list.Add(currentBackground); } list.Add(overlay); view.SetBackgroundDrawable(new LayerDrawable(list.ToArray())); disposables.Add(() => view.SetBackgroundDrawable(null)); } }
private void SetBackground(BindableView view, Drawable drawable) { #pragma warning disable 618 // Using older method for compatibility with API 15 view.SetBackgroundDrawable(drawable); #pragma warning restore 618 }