[Android] Change elevation to use float.minvalue instead of negative infinity (#6560)
authorShane Neuville <shane94@hotmail.com>
Thu, 20 Jun 2019 02:54:07 +0000 (20:54 -0600)
committerSamantha Houts <samhouts@users.noreply.github.com>
Thu, 20 Jun 2019 02:54:07 +0000 (19:54 -0700)
* change negative infinity to float.minvalue

* api 19 fixes

Xamarin.Forms.Platform.Android/Renderers/ShellFlyoutTemplatedContentRenderer.cs
Xamarin.Forms.Platform.Android/ViewExtensions.cs

index 2c86e59..57e1abe 100644 (file)
@@ -92,8 +92,7 @@ namespace Xamarin.Forms.Platform.Android
 
                        _bgImage = new ImageView(context)
                        {
-                               LayoutParameters = new LP(coordinator.LayoutParameters),
-                               Elevation = float.NegativeInfinity
+                               LayoutParameters = new LP(coordinator.LayoutParameters)
                        };
 
                        UpdateFlyoutHeaderBehavior();
@@ -167,7 +166,12 @@ namespace Xamarin.Forms.Platform.Android
                                }
 
                                if (_rootView.IndexOfChild(_bgImage) == -1)
-                                       _rootView.AddView(_bgImage);
+                               {
+                                       if(_bgImage.SetElevation(float.MinValue))
+                                               _rootView.AddView(_bgImage);
+                                       else
+                                               _rootView.AddView(_bgImage, 0);
+                               }
                        }
                }
 
index ed540e5..2645a88 100644 (file)
@@ -93,5 +93,14 @@ namespace Xamarin.Forms.Platform.Android
 
                        view.ClipToOutline = value;
                }
+
+               public static bool SetElevation(this AView view, float value)
+               {
+                       if (view.IsDisposed() || !Forms.IsLollipopOrNewer)
+                               return false;
+
+                       view.Elevation = value;
+                       return true;
+               }
        }
 }
\ No newline at end of file