Reputation: 3
So I am using lopspower/CircularImageView Library to create a Circular Image View like this
<com.mikhaellopez.circularimageview.CircularImageView
android:id="@+id/nav_header_profile_pic"
android:layout_width="100dp"
android:layout_height="100dp"
android:gravity="center"
android:src="@drawable/square_shape"
android:foreground="@drawable/foreground_add_image"
app:civ_border_color="@color/colorPrimaryDark"
app:civ_border_width="2dp"
app:civ_shadow="true"
app:civ_shadow_radius="2"
app:civ_shadow_color="@color/dark_grey"/>
and I have the drawable resources like this
square_shape.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/colorPrimaryLight"/>
</shape>
</item>
</layer-list>
and
foreground_add_image.xml
<?xml version="1.0" encoding="utf-8"?>
<inset
xmlns:android="http://schemas.android.com/apk/res/android"
android:inset="30dp"
android:drawable="@drawable/ic_add_a_photo_white_24dp" />
the foreground image is being displayed but the android:src="@drawable/square_shape" is not being displayed.
Upvotes: 0
Views: 74
Reputation: 240
'android:src' tag is for the image source. You need to use 'android:background' for the square_shape
<com.mikhaellopez.circularimageview.CircularImageView
android:id="@+id/nav_header_profile_pic"
android:layout_width="100dp"
android:layout_height="100dp"
android:gravity="center"
android:foreground="@drawable/foreground_add_image"
app:civ_border_color="@color/colorPrimaryDark"
app:civ_border_width="2dp"
app:civ_shadow="true"
app:civ_shadow_radius="2"
app:civ_shadow_color="@color/dark_grey"
android:background="@drawable/square_shape"
android:src="@drawable/your_image_file_name"/>
Upvotes: 1
Reputation: 2004
As par my knowledge you just need to use this to show image in circular view.
<com.mikhaellopez.circularimageview.CircularImageView
android:id="@+id/ivCircularImage"
android:layout_width="300dp"
android:layout_height="300dp"
android:src="@drawable/homeLogo"
app:civ_border="true"
app:civ_border_color="#3f51b5"
app:civ_border_width="8dp"
app:civ_shadow="true"
app:civ_shadow_color="#3f51b5"
app:civ_shadow_radius="10" />
Upvotes: 0