I am working on a Xamarin Android application, and I need to make a Circular ImageView
.
How can this be achieved?
To draw a circle, make the WidthRequest and HeightRequest properties of the Ellipse object equal. For information about drawing a dashed ellipse, see Draw dashed shapes.
IsClippedToBounds property -Determines if the Layout should clip its children to its bounds. – This makes the image have a visual effect as if it were inside the Frame, adhering with all the properties that the Frame indicates, in this case, it takes the circular shape.
I use the RoundedImageView library. It's written in Java, but you can write a binding to it without much problems. Once you do, you can simply add this to your .axml
:
<RoundedImageView
local:riv_corner_radius="15dp"
local:riv_oval="false"
android:scaleType="centerCrop"
android:layout_width="30dp"
android:layout_height="30dp" />
Edit for future readers: I wrote a port of the RoundedImageView
for Xamarin.Android, based on the library linked on this post. The source code can be found here and the NuGet package here. A MvxRoundedImageView
is also included for use with MvvmCross.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With