Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Padding between border and the image #133

Closed
b-runo opened this issue Jun 8, 2016 · 6 comments
Closed

Add Padding between border and the image #133

b-runo opened this issue Jun 8, 2016 · 6 comments
Labels

Comments

@b-runo
Copy link

b-runo commented Jun 8, 2016

How to create a padding between the border and the image?
Like this image

@b-runo b-runo changed the title Padding Add Padding between border and the image Jun 8, 2016
@iamtodor
Copy link

It could be useful
+1

@hdodenhof
Copy link
Owner

There is no native support for this, but you should be able to achieve it by subclassing CircleImageView and overriding onDraw with some custom behavior while still calling super.onDraw(). An easier way would probably be wrapping the CircleImageView in a FrameLayout which draws the border and has some padding.

@b-runo
Copy link
Author

b-runo commented Jun 13, 2016

I know I'm already asking a lot but have a sample code 😅.

@hdodenhof
Copy link
Owner

In your layout:

<FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="4dp"
    android:background="@drawable/circle_background">

    <de.hdodenhof.circleimageview.CircleImageView
        android:layout_width="96dp"
        android:layout_height="96dp"
        android:src="@drawable/foobar"/>

</FrameLayout>

And drawable/circle_background.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">

    <stroke
        android:width="1dp"
        android:color="#FFFFFF"/>

</shape>

@samitparadedocs
Copy link

Great work.
Thank you.

@b-runo
Copy link
Author

b-runo commented Jun 23, 2016

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants