Mahmudul Hasan
Mahmudul Hasan

Reputation: 25

Circle Image View not showing up

<de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/image_view"
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:background="@color/colorPrimary" />

Added and Synced in Dependencies the below code:

implementation 'de.hdodenhof:circleimageview:3.1.0'

see the below picture for the problem. https://drive.google.com/open?id=17yYcUBQFQr0NiykBtEfCISBI4fMWT1vM

Upvotes: 1

Views: 4623

Answers (3)

Malik Saifullah
Malik Saifullah

Reputation: 584

Updated Answer

Google has released ShapeableImageView which provides wide range of shapes. No need to use 3rd party libraries now.

To work with ShapeableImageView in your android project, you need to add dependency material design library.

implementation 'com.google.android.material:material:1.2.0'

Define a style in your styles.xml

<style name="ShapeAppearanceOverlay.App.CornerSize50Percent" parent="">
    <item name="cornerSize">50%</item>
</style>

and last add this shapeableImageView in your xml.

<com.google.android.material.imageview.ShapeableImageView
    android:layout_width="150dp"
    android:layout_height="150dp"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:srcCompat="@mipmap/ic_launcher"
    android:layout_margin="10dp"
    app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.App.CornerSize50Percent"
    />

now only circle you can create different shapes on imageview with right styling.

Upvotes: 0

Muhammed shamshad p
Muhammed shamshad p

Reputation: 131

Add this in your gradle

 dependencies {
      ...
      implementation 'de.hdodenhof:circleimageview:3.1.0'
  }

xml be like

<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"[![enter image description here][1]][1]
    android:src="@drawable/profile"
    app:civ_border_width="2dp"
    app:civ_border_color="#FF000000"/>

for more info about this library visit in :https://github.com/hdodenhof/CircleImageView

Upvotes: 0

IntelliJ Amiya
IntelliJ Amiya

Reputation: 75798

You should use CircleImageView

implementation 'de.hdodenhof:circleimageview:3.1.0'

XML

<de.hdodenhof.circleimageview.CircleImageView
    android:layout_width="70dp"
    android:layout_height="70dp"
    android:src="@drawable/add_icon"
    app:civ_border_width="1dp"
    app:civ_border_color="#FF000000"/>

Upvotes: 1

Related Questions