Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Android] Update ClipBounds when View bounds changes #3909

Merged
merged 1 commit into from Sep 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,49 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

#if UITEST
using Xamarin.Forms.Core.UITests;
using Xamarin.UITest;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.ManualReview)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.None, 888888, "Bounds clipping does not update when View bounds change", PlatformAffected.Android)]
public class ViewClipBoundsShouldUpdate : TestContentPage
{
const string Success = "Success";

class TestContentView : ContentView
{
public TestContentView()
{
Content = new Label { Text = Success };

IsClippedToBounds = true;
}
}

protected override void Init()
{
var layout = new StackLayout
{
Children =
{
new Label
{
Text = $"If '{Success}' displays below then this test has passed."
},
new TestContentView()
}
};

Content = layout;
}

}
}
Expand Up @@ -502,6 +502,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Issue3342.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue3415.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue3049.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewClipBoundsShouldUpdate.cs" />
<Compile Include="$(MSBuildThisFileDirectory)_Template.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla56298.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla42620.cs" />
Expand Down
7 changes: 7 additions & 0 deletions Xamarin.Forms.Platform.Android/VisualElementTracker.cs
Expand Up @@ -104,6 +104,13 @@ public void UpdateLayout()
Performance.Stop(reference, "MeasureAndLayout");
}

// If we're running sufficiently new Android, we have to make sure to update the ClipBounds to
// match the new size of the ViewGroup
if ((int)Build.VERSION.SdkInt >= 18)
{
UpdateClipToBounds();
}

Performance.Stop(reference);

//On Width or Height changes, the anchors needs to be updated
Expand Down