1

I am new in android,I need to display the image in circular form but some images which have more than width and height from custom circular image view then displaying the image as streching form, But I want to show the image with reduce the size of image and show in circle. I am using universal image loader for loading the images.Please help me How to do this.

Thanks in advance

Anuj Kumar
  • 13
  • 1
  • 3

2 Answers2

2

in the build.gradle file , put this line in the dependencies:

compile 'de.hdodenhof:circleimageview:2.0.0'

this is a library for the circular imageView. then in the xml you can use it like:

<de.hdodenhof.circleimageview.CircleImageView
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:id="@+id/profile_image"
     android:layout_width="60dp"
     android:layout_height="60dp"
     android:scaleType="centerCrop"
     android:src="@drawable/male_profile_image"
     app:civ_border_width="0dp"/>
Khalid Taha
  • 3,183
  • 5
  • 27
  • 43
1

You can achieve this by using a circle image view library

implementation 'de.hdodenhof:circleimageview:2.2.0'

Next, You'll add it to your layout

<de.hdodenhof.circleimageview.CircleImageView
            android:id="@+id/ptv_pic"
            android:layout_width="120dp"
            android:layout_height="100dp"

            android:src="@drawable/ptv" />

Lastly, create a drawable file to match the src stated above "ptv" (Give it any name you'd like of course)

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

<item
    android:drawable="@mipmap/yourImage" (Here is where you'll add the image)
    android:width="50dp"  (Adjust the width and height here)
    android:height="50dp"
    />

</layer-list >
Kezxi
  • 63
  • 6