Browse Source

Resize on HideWithSize

Max Katz 3 years ago
parent
commit
76c3691fb6

+ 3 - 1
src/Android/Avalonia.Android/Platform/AndroidNativeControlHostImpl.cs

@@ -116,6 +116,8 @@ namespace Avalonia.Android.Platform
             {
                 CheckDisposed();
                 _view.Visibility = ViewStates.Gone;
+                _view.LayoutParameters = new ViewGroup.LayoutParams(Math.Max(1, (int)size.Width), Math.Max(1, (int)size.Height));
+                _view.RequestLayout();
             }
 
             public void ShowInBounds(Rect bounds)
@@ -126,7 +128,7 @@ namespace Avalonia.Android.Platform
 
                 bounds *= _attachedTo._avaloniaView.TopLevelImpl.RenderScaling;
                 _view.Visibility = ViewStates.Visible;
-                _view.LayoutParameters = new FrameLayout.LayoutParams((int)bounds.Width, (int)bounds.Height)
+                _view.LayoutParameters = new ViewGroup.MarginLayoutParams(Math.Max(1, (int)bounds.Width), Math.Max(1, (int)bounds.Height))
                 {
                     LeftMargin = (int)bounds.X,
                     TopMargin = (int)bounds.Y

+ 3 - 1
src/iOS/Avalonia.iOS/NativeControlHostImpl.cs

@@ -118,7 +118,9 @@ namespace Avalonia.iOS
             public void HideWithSize(Size size)
             {
                 CheckDisposed();
+
                 _view.Hidden = true;
+                _view.Frame = new CGRect(0d, 0d, Math.Max(1d, size.Width), Math.Max(1d, size.Height));
             }
 
             public void ShowInBounds(Rect bounds)
@@ -127,7 +129,7 @@ namespace Avalonia.iOS
                 if (_attachedTo == null)
                     throw new InvalidOperationException("The control isn't currently attached to a toplevel");
 
-                _view.Frame = new CGRect(bounds.X, bounds.Y, bounds.Width, bounds.Height);
+                _view.Frame = new CGRect(bounds.X, bounds.Y, Math.Max(1d, bounds.Width), Math.Max(1d, bounds.Height));
                 _view.Hidden = false;
             }
         }