ghasem deh
ghasem deh

Reputation: 718

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

Upvotes: 1

Views: 11366

Answers (2)

Keshav Gera
Keshav Gera

Reputation: 11264

Updated dependencies

compile 'de.hdodenhof:circleimageview:2.1.0'

Border Color White using this and set width according to your need

app:border_color="@color/white"

app:border_width="1dp"

<de.hdodenhof.circleimageview.CircleImageView
     android:id="@+id/user_profile_image"
     android:layout_width="95dp"
     android:layout_height="95dp"
     android:layout_gravity="center"
     android:src="@mipmap/avatar_male"
     app:border_color="@color/white"
     app:border_width="1dp"
    />

enter image description here

Upvotes: 1

Jins Lukose
Jins Lukose

Reputation: 707

if you are using Android studio please add this dependency

dependencies {
...
compile 'de.hdodenhof:circleimageview:2.1.0'}

then use this on your layout

<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/profile_image"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="@drawable/profile"
app:civ_border_width="2dp"
app:civ_border_color="#FF000000"/>

this will help you

Upvotes: 4

Related Questions