Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Circular ImageView on Xamarin

I am working on a Xamarin Android application, and I need to make a Circular ImageView.

How can this be achieved?

like image 249
Dhruv Gohil Avatar asked Aug 19 '15 14:08

Dhruv Gohil


People also ask

How do I draw a circle in xamarin?

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.

What is IsClippedToBounds?

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.


1 Answers

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.

like image 199
William Barbosa Avatar answered Sep 28 '22 18:09

William Barbosa