ghasem deh ghasem deh - 4 years ago 136
Android Question

how to fit in circular imageView?

i use circular image_View in my app , but when select image for image_View image not fit to image_View

this image_View : (xml)

<ImageView
android:id="@+id/user_profile_pic"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_below="@+id/user_cover_pic"
android:layout_centerHorizontal="true"
android:layout_marginTop="-60dp"
android:background="@drawable/circular_border"
android:elevation="6dp"
android:scaleType="centerCrop"
android:padding="10dp"
android:src="@drawable/ghasem"
tools:ignore="ContentDescription,UnusedAttribute" />


this circular border :

<

?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="100dp" />
<solid android:color="#fff" />
<stroke
android:width="3dip"
android:color="@color/colorAccent" />
<padding
android:bottom="4dp"
android:left="4dp"
android:right="4dp"
android:top="4dp" />
</shape>


enter image description here

Answer Source

Do you want to use only code or you are ok with library too? If you are ok with library may I suggest using this library, helped me a lot.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download