|
11 | 11 | using Xamarin.CommunityToolkit.Effects; |
12 | 12 | using Xamarin.Forms; |
13 | 13 | using Xamarin.Forms.Platform.Android; |
14 | | -using AndroidOS = Android.OS; |
15 | 14 | using AView = Android.Views.View; |
16 | 15 | using Color = Android.Graphics.Color; |
17 | 16 |
|
@@ -76,7 +75,9 @@ protected override void OnAttached() |
76 | 75 |
|
77 | 76 | if (Group == null) |
78 | 77 | { |
79 | | - View.Foreground = ripple; |
| 78 | + if (Build.VERSION.SdkInt >= BuildVersionCodes.M) |
| 79 | + View.Foreground = ripple; |
| 80 | + |
80 | 81 | return; |
81 | 82 | } |
82 | 83 |
|
@@ -115,7 +116,7 @@ protected override void OnDetached() |
115 | 116 | View.Touch -= OnTouch; |
116 | 117 | View.Click -= OnClick; |
117 | 118 |
|
118 | | - if (View.Foreground == ripple) |
| 119 | + if (Build.VERSION.SdkInt >= BuildVersionCodes.M && View.Foreground == ripple) |
119 | 120 | View.Foreground = null; |
120 | 121 | } |
121 | 122 |
|
@@ -316,7 +317,10 @@ void EndRipple() |
316 | 317 |
|
317 | 318 | void CreateRipple() |
318 | 319 | { |
319 | | - var drawable = Group != null ? View?.Background : View?.Foreground; |
| 320 | + var drawable = Build.VERSION.SdkInt >= BuildVersionCodes.M && Group == null |
| 321 | + ? View?.Foreground |
| 322 | + : View?.Background; |
| 323 | + |
320 | 324 | var isEmptyDrawable = Element is Layout || drawable == null; |
321 | 325 |
|
322 | 326 | if (drawable is RippleDrawable) |
@@ -355,12 +359,11 @@ ColorStateList GetColorStateList() |
355 | 359 |
|
356 | 360 | void OnLayoutChange(object sender, AView.LayoutChangeEventArgs e) |
357 | 361 | { |
358 | | - var group = (ViewGroup)sender; |
359 | | - if (group == null || (Group as IVisualElementRenderer)?.Element == null || rippleView == null) |
| 362 | + if (!(sender is AView view) || (Group as IVisualElementRenderer)?.Element == null || rippleView == null) |
360 | 363 | return; |
361 | 364 |
|
362 | | - rippleView.Right = group.Width; |
363 | | - rippleView.Bottom = group.Height; |
| 365 | + rippleView.Right = view.Width; |
| 366 | + rippleView.Bottom = view.Height; |
364 | 367 | } |
365 | 368 |
|
366 | 369 | sealed class AccessibilityListener : Java.Lang.Object, |
|
0 commit comments