-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[F100] Rounded Corners #1754
Comments
One common requirement is to create an ellipse / circle (depending on geometry of the view). This can't be done easily with a numerical value for border rounding - it's better done as a percentage, or with a flag that says "create an ellipse". Please consider using "special" values for the flag (e.g. -2 for ellipse), or making the values work like |
Perhaps this could eventually be extended to allow a |
Maybe the right option is to have an interface called |
Interesting idea! |
make sure the default value is I'm wondering if we couldn't put that property in BorderElement |
https://github.com/NAXAM/effects-xamarin-forms it covers borders, radius and shadows on Views |
This would be a great enhancement, a helping hand for making layouts simpler and take less time to render. Please see my comment here #1998 (comment) Nothing new maybe, I think you are aware of it. I think this property should be on the View class, and the implementation in first phase should be starting with ContentView, StackLayout, Grid, Entry. I think we have it already on Frame and Button? One interesting this is once we have it on Image, we will be able to have a very simple way to implement round profile images :) There will be no need to add extra plugins. |
It technically suffices, but it’s semantically wrong
… On 2 Mar 2018, at 11:04, Andrei N ***@***.***> wrote:
@hartez <https://github.com/hartez> Is there a need to have a CornerRadius type? Why doesn't Thickness suffice?
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub <#1754 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AATGqy7rgadWyDk7tpGObuEJkXObW67Yks5taRk6gaJpZM4RzMVt>.
|
@StephaneDelcroix I figured that out, notice I already had deleted my comment. Thanks. |
I would also suggest that the property CornerRadius be a Thickness, not a Single, permitting us to round each corner separately. |
This is a good idea! Could this also apply to non-view type elements in xaml? Right now, Button does have border radius, but Entry does not, for example. I have a project right now where the design calls for a lot of rounded features, and this issue addresses some of those, but not Entry. |
@ederbond I was looking into implement this (at least as an Effect for now) and having some weirdness on Android trying to get a ViewOutlineProvider to return an outline with different corner radii specified to actually render. Doing a simple same corner radius on all corners works absolutely fine, but it seems like an outline clipped with different corner radii is not supported. I see you posted a screenshot here presumably with this working. I'm curious what approach you took as the few I've tried haven't been successful so far (and it looks like Android limitations). EDIT: Nevermind, I didn't realize the BoxView renderer already did this and is just using a GradientDrawable and setting it to the background... Took that approach and it's working well. |
So just for reference, this is my code:
The iOS Renderer
The Android Renderer:
Usage:
|
Worth mentioning Pancake View. I've also got some code which does almost exactly the same thing as PancakeView but as an Effect instead, however it doesn't work on UWP properly (ultimately adding the effect to things like Grid or StackLayout ends up rendiner a UWP Panel which can't have CornerRadius set on it), and it has the same Android limitation where you can either have Shadows and Uniform corner radius, or no shadows and different corner radii. This isn't the easiest one to actually implement properly without these limitations unfortunately. |
@Redth I’m currently in the process of implementing a way that separate rounded corner radii AND shadow work in PancakeView on Android. It involves creating your own path and feeding that to the ViewOutlineProvider. However that solution creates additional complexity with clipping which you would also need to do manually based on the same path. I’m convinced it’s possible but my efforts are currently halted for a few weeks of well deserved holiday 😅 |
@Redth I can confirm that this CAN be done using
|
@sthewissen awesome! Would love to see what you come up with for getting android to play more nicely! |
@Redth It's currently live in PancakeView 1.3.3. Seems to work like a charm. |
@Redth @jsuarezruiz @StephaneDelcroix @hartez @davidortinau please consider bringing part of the code from PacakeView to every Layout view of #dotnetmaui so we developers can set BorderColor, BorderWidth, CornerRadius, and Shadow to any visible control. |
This will not happen anymore for Xamarin.Forms. I think there is much to do about borders and corners and such in .NET MAUI, so there is a good chance that will all be better there. If this is still important to you, make sure to check the .NET MAUI repo and see if it's already on the roadmap or open an issue with a detailed feature request. Thanks! |
Rationale
Rounded corners are a common visual requirement which Forms does not support without custom renderers. Forms should provide a common interface for defining rounded corners on Views.
Implementation
We need to add an interface for defining what's required for a View to implement corner rounding (and provide CSS support):
The CornerRadius BindableProperty can be implemented in one place:
Renderer implementations should be careful to take Borders into consideration.
The following Views are candidates for rounded corners:
BoxView (in progress: #1709)
ImageView
StackLayout
Grid
AbsoluteLayout
ScrollView
(probably others)
Difficulty: Easy
Providing the interface is simple; individual implementations may vary in difficulty.
The text was updated successfully, but these errors were encountered: