question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CornerRadius issue with MaterialContentView in CollectionView on Android

See original GitHub issue

The CornerRadius of MaterialContentView is not working properly when using it in a CollectionView. The bug is only on Android. No issue on iOS. Version 2.1.0-beta1 (androidx) with most recent version of xamarin forms.

Here is a sample repro project. repro.zip

Here is a screen record of both actual and expected behavior. actual2 expected2

I think the issue is in XamarinBackgroundKit.Android.PathProviders.RoundRectPathProvider. The CanHandledByOutline method uses CornerRadii, but it does not seem to hold the correct value when IsPathDirty==true. https://github.com/ChasakisD/Xamarin.Forms.BackgroundKit/blob/4e7c51bcdaae90f738a0f220d520f97a8d49c69a/src/XamarinBackgroundKit.Android/PathProviders/RoundRectPathProvider.cs#L16

So here is a fix that works in my scenario. Instead of:

public override bool CanHandledByOutline =>
      Math.Abs(CornerRadii.Sum() / CornerRadii.Length - CornerRadii[0]) < 0.0001;

check the value of IsPathDirty first:

public override bool CanHandledByOutline =>
      !IsPathDirty && Math.Abs(CornerRadii.Sum() / CornerRadii.Length - CornerRadii[0]) < 0.0001;

What do you think ? Thanks !

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ChasakisDcommented, Mar 5, 2022

@tranb3r Version 2.1.2 released to nuget. Thank you very much!

1reaction
ChasakisDcommented, Mar 4, 2022

Merged the androidx branch

Read more comments on GitHub >

github_iconTop Results From Across the Web

Image in collection view cell inside of uitableviewcell does ...
Basically what's happening is that when you set the corner radius at that time your- img_Photo.frame.height is different & then after scrolling ...
Read more >
[Bug] When using a layout with a Corner Radius it's not ...
[Bug] When using a layout with a Corner Radius it's not possible to remove the orange background from a Selected CollectionView Element # ......
Read more >
How to set corner radius to my listview selected item border
I want to set a corner radius to the red border ... to display data instead of ListView, because CollectionView don't need to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found