I want to fit a rectangular image in a circular view.That is image with white rounded border.I tried several methods but none of them worked properly.Can anyone help please?
Asked
Active
Viewed 1,168 times
0
-
1this worked for me... https://stackoverflow.com/a/22105820/5617846 – Yash Amin Jun 12 '17 at 10:10
-
Thanks for the reply. but the above method didn't worked for me:( – Anu Jun 12 '17 at 10:18
-
Possible duplicate of [ImageView in circular through xml](https://stackoverflow.com/questions/22105775/imageview-in-circular-through-xml) – RED_ Jun 12 '17 at 10:21
-
@RED_ But sir when i tried using circle imageview it looks perfect in the android studio design but when i run the code it displays a round without my image. – Anu Jun 12 '17 at 10:26
-
Soory!! This worked for me.. https://stackoverflow.com/a/35287222/5617846 ... Run the app to see circular imageview.... – Yash Amin Jun 12 '17 at 10:40
2 Answers
1
Try it out this layout you will get circular ImageView..
<android.support.v7.widget.CardView
android:id="@+id/circularView"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:layout_margin="5dp"
android:elevation="12dp"
android:innerRadius="0dp"
android:shape="ring"
android:thicknessRatio="1.9"
android:layout_gravity="center"
app:cardBackgroundColor="@color/your_color"
app:cardCornerRadius="30dp">
<ImageView
android:id="@+id/ivId"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
/>
</android.support.v7.widget.CardView>

ice spirit
- 1,425
- 3
- 16
- 32
0
To put a rectangular picture into a circle imageView
you can use this library:
Circle ImageView

Mahdi-Malv
- 16,677
- 10
- 70
- 117
-
i used circleimageview. but in android studio design page the image looked perfect.but when i run that code in my emulator it displays a black round without my image. – Anu Jun 12 '17 at 10:23
-
Never had this problem. If you couldn't fix it i suggest you try this library. – Mahdi-Malv Jun 12 '17 at 10:45
-