A circular ImageView for Android

Overview

CircleImageView

A fast circular ImageView perfect for profile images. This is based on RoundedImageView from Vince Mi which itself is based on techniques recommended by Romain Guy.

CircleImageView

It uses a BitmapShader and does not:

  • create a copy of the original bitmap
  • use a clipPath (which is neither hardware accelerated nor anti-aliased)
  • use setXfermode to clip the bitmap (which means drawing twice to the canvas)

As this is just a custom ImageView and not a custom Drawable or a combination of both, it can be used with all kinds of drawables, i.e. a PicassoDrawable from Picasso or other non-standard drawables (needs some testing though).

Gradle

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

Usage

<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"/>

Limitations

  • The ScaleType is always CENTER_CROP and you'll get an exception if you try to change it. This is (currently) by design as it's perfectly fine for profile images.
  • Enabling adjustViewBounds is not supported as this requires an unsupported ScaleType
  • If you use an image loading library like Picasso or Glide, you need to disable their fade animations to avoid messed up images. For Picasso use the noFade() option, for Glide use dontAnimate(). If you want to keep the fadeIn animation, you have to fetch the image into a Target and apply a custom animation yourself when receiving the Bitmap.
  • Using a TransitionDrawable with CircleImageView doesn't work properly and leads to messed up images.

FAQ

How can I use a VectorDrawable with CircleImageView?

Short answer: you shouldn't. Using a VectorDrawable with CircleImageView is very inefficient. You should modify your vectors to be in a circular shape and use them with a regular ImageView instead.

Why doesn't CircleImageView extend AppCompatImageView?

Extending AppCompatImageView would require adding a runtime dependency for the support library without any real benefit.

How can I add a selector (e.g. ripple effect) bound to a circle?

There's currently no direct support for a circle bound selector but you can follow these steps to implement it yourself.

How can I add a gap between image and border?

Adding a gap is also not supported directly but there's a workaround.

Changelog

  • 3.1.0
    • Align bitmap paint flags with BitmapDrawable (improves scaling)
  • 3.0.2
    • Fix NPE during initialization on API level <= 19
    • Fix wrong outline being provided if circular transformation is disabled
  • 3.0.1
    • Fix touch event not fired if view is empty
    • Fix touchable area limited to a circle even if transformation is disabled
  • 3.0.0
    • Limit touch event handling to circle area
    • Migrate to AndroidX
    • Remove deprecated properties and methods
  • 2.2.0
    • Add support for elevation
    • Add circle background color attribute to replace fill color
  • 2.1.0
    • Add support for padding
    • Add option to disable circular transformation
    • Fix hairline gap being drawn between image and border under some conditions
    • Fix NPE when using tint attribute (which is not supported)
    • Deprecate fill color as it seems to cause quite some confusion
  • 2.0.0
    • BREAKING: Custom xml attributes are now prefixed with "civ_"
    • Graceful handling of incompatible drawables
    • Add support for a fill color shown behind images with transparent areas
    • Fix dimension calculation issues with small images
    • Fix bitmap not being cleared when set to null
  • 1.3.0
    • Add setBorderColorResource(int resId)
    • Add resource type annotations
    • Add border_overlay attribute to allow drawing border on top of the base image
  • 1.2.2
    • Add ColorFilter support
  • 1.2.1
    • Fix ColorDrawables not being rendered properly on Lollipop
  • 1.2.0
    • Add support for setImageURI(Uri uri)
    • Fix view not being initialized when using CircleImageView(Context context)
  • 1.1.1
    • Fix border being shown although border width is set to 0
  • 1.1.0
    • Add support for ColorDrawables
    • Add getters and setters for border color and border width
  • 1.0.1
    • Prevent crash due to OutOfMemoryError
  • 1.0.0
    • Initial release

License

Copyright 2014 - 2020 Henning Dodenhof

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • Error: android.view.InflateException: Binary XML file line #28: Error inflating class de.hdodenhof.circleimageview.CircleImageView

    Error: android.view.InflateException: Binary XML file line #28: Error inflating class de.hdodenhof.circleimageview.CircleImageView

    Hi, Thank you for your project ^^;

    I found an crash. I just add [compile 'com.google.android.gms:play-services-analytics:8.3.0'] in my gradle, and add code in my main activity. however, if I delete that code my app is ok.

    this is my build.gradle

    apply plugin: 'com.android.application'
    apply plugin: 'com.google.gms.google-services'
    
    
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.1"
    
    
    
        defaultConfig {
            applicationId "com.xxx.xxx"
            minSdkVersion 15
            targetSdkVersion 23
            versionCode 152
            versionName "4.4.1"
            multiDexEnabled true
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        packagingOptions {
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
        }
        /*productFlavors {
            dev {
                minSdkVersion 15
            }
            prod {
                minSdkVersion 15
            }
        }*/
    }
    
    
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:23.1.0'           //Support Library
        compile 'com.android.support:cardview-v7:23.1.0'            //CardView Library
        compile 'com.android.support:gridlayout-v7:23.1.0'          //GridLayout Library
        compile 'com.android.support:recyclerview-v7:23.1.0'
        compile 'com.android.support:palette-v7:23.1.0'
        compile 'com.android.support:design:23.1.0'                 //Design Support Library
    
        compile 'com.github.rey5137:material:1.2.1'                 //Material Design Support/ https://github.com/rey5137/material
    
        compile 'com.squareup.retrofit:retrofit:1.9.0'              //Network Library
        compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
        compile 'com.github.bumptech.glide:glide:3.6.1'             //Network Image Library/    https://github.com/bumptech/glide
        compile 'com.github.bumptech.glide:okhttp-integration:1.3.1'
        compile 'com.squareup.okhttp:okhttp:2.5.0'                  //Network Client/           http://square.github.io/okhttp/
    
        compile 'de.hdodenhof:circleimageview:2.0.0'                //Circle Image             https://github.com/hdodenhof/CircleImageView
    
        compile 'com.facebook.android:facebook-android-sdk:4.1.0'   //facebook sdk
    
        compile 'com.google.android.gms:play-services-analytics:8.3.0'
    }
    
    

    and my Application.java

     private Tracker tracker;
    
        synchronized public Tracker getDefaultTracker() {
            if (tracker == null) {
                GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
                tracker = analytics.newTracker(R.xml.global_tracker);
            }
    
            return tracker;
        }
    

    and my MainActivity.java

    Application application = (Application) getApplication();
            Tracker tracker = application.getDefaultTracker();
            tracker.setScreenName(MainActivity.class.getName());
            tracker.send(new HitBuilders.ScreenViewBuilder().build());
    

    and than Exception message

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx.xxx/com.xxx.xxx.activity.MainActivity}: android.view.InflateException: Binary XML file line #28: Error inflating class de.hdodenhof.circleimageview.CircleImageView
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2067)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2092)
        at android.app.ActivityThread.access$600(ActivityThread.java:138)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4874)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
        at dalvik.system.NativeStart.main(Native Method)
    Caused by: android.view.InflateException: Binary XML file line #28: Error inflating class de.hdodenhof.circleimageview.CircleImageView
        at android.view.LayoutInflater.createView(LayoutInflater.java:613)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
        at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:736)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
        at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
        at com.xxx.xxx.activity.MainActivity.onCreate(MainActivity.java:96)
        at android.app.Activity.performCreate(Activity.java:5008)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2031)
        ... 11 more
    Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.constructNative(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
        at android.view.LayoutInflater.createView(LayoutInflater.java:587)
        ... 28 more
    Caused by: java.lang.NoClassDefFoundError: de.hdodenhof.circleimageview.R$styleable
        at de.hdodenhof.circleimageview.CircleImageView.<init>(CircleImageView.java:71)
        at de.hdodenhof.circleimageview.CircleImageView.<init>(CircleImageView.java:65)
        ... 31 more
    

    thank you,

    opened by prographer 22
  • Error:(23, 13) Failed to resolve: de.hdodenhof:circleimageview:2.0.0

    Error:(23, 13) Failed to resolve: de.hdodenhof:circleimageview:2.0.0

    Hi, I am having failed to resolved error in my android studio project, here's my build.gradle settings,

    apply plugin: 'com.android.application'
    android {
        compileSdkVersion 23
        buildToolsVersion '23.0.0'
        useLibrary 'org.apache.http.legacy'
    
        defaultConfig {
            applicationId "my.package.name.appname"
            minSdkVersion 9
            targetSdkVersion 23
        }
    
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            }
        }
    }
    
    dependencies {
        compile files('src/main/Vuforia.jar')
        compile 'com.android.support:appcompat-v7:23.1.0'
        compile 'com.android.support:design:23.1.0'
        compile 'de.hdodenhof:circleimageview:2.0.0'
    }
    
    opened by nileshlg2003 22
  • Could not find class 'de.hdodenhof.circleimageview.CircleImageView$OutlineProvider'

    Could not find class 'de.hdodenhof.circleimageview.CircleImageView$OutlineProvider'

    Hi, I am have an error Could not find class 'de.hdodenhof.circleimageview in my android studio project, here's my build.gradle settings, thankyou

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 26
        defaultConfig {
            vectorDrawables.useSupportLibrary = true
            applicationId "com.fuad.youtube"
            minSdkVersion 15
            targetSdkVersion 26
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:26.1.0'
        implementation 'com.android.support:recyclerview-v7:26.1.0'
        implementation 'com.android.support:cardview-v7:26.1.0'
        implementation 'com.android.support:design:26.+'
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        implementation ("com.github.bumptech.glide:glide:4.6.1") {
            exclude group: "com.android.support"
        }
        implementation "com.android.support:support-fragment:26.1.0"
        implementation 'de.hdodenhof:circleimageview:2.2.0'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.1'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    }
    
    opened by mrifqifuady 13
  • The image gets slightly distorted on pixel perfect images

    The image gets slightly distorted on pixel perfect images

    Hi everyone! Here's a very picky image distortion bug.

    I have a 56dp widget with an 8dp padding. On the other side, I have pixel-perfect images made at 40dp (it's 56dp - 8dp * 2 sides).

    If I apply those images to an ImageView, the result is pixel-perfect. But if I replace that ImageView with a CircleImageView, the result is not pixel-perfect anymore.

    Thinking about it, I think that CircleImageView is getting the 40dp image, then resizing it to 56dp, and then applying the padding and resizing the image again to 40dp.

    Here are some screenshots. First a comparison, and then a screenshot of every case:

    Comparing side by side: Comparison

    Using the plain ImageView: ImageView

    Using CircleImageView: CicleImageView

    By the way, I'm using a local .png file. No network or strange things there.

    Thanks again for your work! And happy New Year 😃 🎆 🎆 🎆

    opened by rocboronat 12
  • App Crashes on API 19 but works fine on above

    App Crashes on API 19 but works fine on above

    03-08 17:53:19.372 7035-7035/com.thetechnilogics.maktaberp.scholars E/dalvikvm: Could not find class 'android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper', referenced from method android.support.v4.view.ViewCompat.addOnUnhandledKeyEventListener
    03-08 17:53:19.372 7035-7035/com.thetechnilogics.maktaberp.scholars E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method android.support.v4.view.ViewCompat.dispatchApplyWindowInsets
    03-08 17:53:19.382 7035-7035/com.thetechnilogics.maktaberp.scholars E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method android.support.v4.view.ViewCompat.onApplyWindowInsets
    03-08 17:53:19.382 7035-7035/com.thetechnilogics.maktaberp.scholars E/dalvikvm: Could not find class 'android.view.View$OnUnhandledKeyEventListener', referenced from method android.support.v4.view.ViewCompat.removeOnUnhandledKeyEventListener
    03-08 17:53:19.392 7035-7035/com.thetechnilogics.maktaberp.scholars E/dalvikvm: Could not find class 'android.support.v4.view.ViewCompat$1', referenced from method android.support.v4.view.ViewCompat.setOnApplyWindowInsetsListener
    03-08 17:53:23.642 7035-7035/com.thetechnilogics.maktaberp.scholars E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
    03-08 17:53:23.672 7035-7035/com.thetechnilogics.maktaberp.scholars E/dalvikvm: Could not find class 'de.hdodenhof.circleimageview.CircleImageView$OutlineProvider', referenced from method de.hdodenhof.circleimageview.CircleImageView.init
    03-08 17:53:25.722 7035-7035/com.thetechnilogics.maktaberp.scholars E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.thetechnilogics.maktaberp.scholars, PID: 7035
        android.view.InflateException: Binary XML file line #61: Error inflating class <unknown>
            at android.view.LayoutInflater.createView(LayoutInflater.java:620)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
            at com.thetechnilogics.maktaberp.scholars.DashBoardFragment.onCreateView(DashBoardFragment.java:79)
            at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
            at android.support.v4.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2646)
            at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2416)
            at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2372)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
            at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5105)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
            at dalvik.system.NativeStart.main(Native Method)
         Caused by: java.lang.reflect.InvocationTargetException
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at android.view.LayoutInflater.createView(LayoutInflater.java:594)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
            at com.thetechnilogics.maktaberp.scholars.DashBoardFragment.onCreateView(DashBoardFragment.java:79) 
            at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439) 
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460) 
            at android.support.v4.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2646) 
            at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2416) 
            at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2372) 
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273) 
            at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:733) 
            at android.os.Handler.handleCallback(Handler.java:733) 
            at android.os.Handler.dispatchMessage(Handler.java:95) 
            at android.os.Looper.loop(Looper.java:136) 
            at android.app.ActivityThread.main(ActivityThread.java:5105) 
            at java.lang.reflect.Method.invokeNative(Native Method) 
            at java.lang.reflect.Method.invoke(Method.java:515) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608) 
            at dalvik.system.NativeStart.main(Native Method) 
         Caused by: java.lang.NullPointerException
            at de.hdodenhof.circleimageview.CircleImageView.applyColorFilter(CircleImageView.java:295)
            at de.hdodenhof.circleimageview.CircleImageView.setColorFilter(CircleImageView.java:285)
            at android.widget.ImageView.setColorFilter(ImageView.java:1111)
            at android.widget.ImageView.setColorFilter(ImageView.java:1123)
            at android.widget.ImageView.<init>(ImageView.java:157)
            at de.hdodenhof.circleimageview.CircleImageView.<init>(CircleImageView.java:98)
            at de.hdodenhof.circleimageview.CircleImageView.<init>(CircleImageView.java:94)
            at java.lang.reflect.Constructor.constructNative(Native Method) 
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
            at android.view.LayoutInflater.createView(LayoutInflater.java:594) 
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
            at com.thetechnilogics.maktaberp.scholars.DashBoardFragment.onCreateView(DashBoardFragment.java:79) 
            at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439) 
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460) 
            at android.support.v4.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2646) 
            at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2416) 
            at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2372) 
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273) 
            at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:733) 
            at android.os.Handler.handleCallback(Handler.java:733) 
            at android.os.Handler.dispatchMessage(Handler.java:95) 
            at android.os.Looper.loop(Looper.java:136) 
            at android.app.ActivityThread.main(ActivityThread.java:5105) 
            at java.lang.reflect.Method.invokeNative(Native Method) 
            at java.lang.reflect.Method.invoke(Method.java:515) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608) 
            at dalvik.system.NativeStart.main(Native Method)
    
    opened by Faisal-Naseer 12
  • Set a background color to an image with transparencies

    Set a background color to an image with transparencies

    I see that setFillColor is now deprecated. We have been using it to set a color inside the circle to an image which has transparencies. So how can we achieve this now without using the fill color?

    opened by bryant1410 10
  • Request: ability to temporary disable rounding the images

    Request: ability to temporary disable rounding the images

    In some cases, instead of a circular image, I wish to show a normal image in the same area that the CircleImageView takes. It would be nice to be able to have a "setOval(boolean)" function, which will enable&disable making the content of the CircleImageView to be rounded. This is better than having a container of it together with a normal ImageView.

    Not only that, but for drawables that exist as XML files (even those that are already round), it would be better to disable the rounding of them, instead of creating new bitmaps using getBitmapFromDrawable .

    enhancement 
    opened by AndroidDeveloperLB 10
  • Error inflating class de.hdodenhof.circleimageview.CircleImageView

    Error inflating class de.hdodenhof.circleimageview.CircleImageView

    user Android viewBind cause: Binary XML file line #23 in com.nowcoder.app.florida:layout/view_header: Error inflating class de.hdodenhof.circleimageview.CircleImageView

    How can I fix it?

    opened by dreamguagua 9
  • Error while load CircleImageView on Android 4

    Error while load CircleImageView on Android 4

    Hi,

    Im getting the error on Android 4:

    6 20:35:02.772 20727-20727/br.com.ubook.ubooktim W/dalvikvm: Unable to resolve superclass of Lde/hdodenhof/circleimageview/CircleImageView$OutlineProvider; (272)
        Link of class 'Lde/hdodenhof/circleimageview/CircleImageView$OutlineProvider;' failed
    08-16 20:35:02.782 20727-20727/br.com.ubook.ubooktim E/dalvikvm: Could not find class 'de.hdodenhof.circleimageview.CircleImageView$OutlineProvider', referenced from method de.hdodenhof.circleimageview.CircleImageView.init
    08-16 20:35:02.782 20727-20727/br.com.ubook.ubooktim W/dalvikvm: VFY: unable to resolve new-instance 2338 (Lde/hdodenhof/circleimageview/CircleImageView$OutlineProvider;) in Lde/hdodenhof/circleimageview/CircleImageView;
    08-16 20:35:02.782 20727-20727/br.com.ubook.ubooktim D/dalvikvm: VFY: replacing opcode 0x22 at 0x000e
    08-16 20:35:02.802 20727-20727/br.com.ubook.ubooktim W/dalvikvm: Unable to resolve superclass of Lde/hdodenhof/circleimageview/CircleImageView$OutlineProvider; (272)
        Link of class 'Lde/hdodenhof/circleimageview/CircleImageView$OutlineProvider;' failed
    08-16 20:35:02.802 20727-20727/br.com.ubook.ubooktim D/dalvikvm: DexOpt: unable to opt direct call 0x3186 at 0x11 in Lde/hdodenhof/circleimageview/CircleImageView;.init
    08-16 20:35:02.962 20727-20797/br.com.ubook.ubooktim D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=7043, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=7834691520531409482}]
    08-16 20:35:03.012 20727-20727/br.com.ubook.ubooktim D/AndroidRuntime: Shutting down VM
    08-16 20:35:03.012 20727-20727/br.com.ubook.ubooktim W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x4194fda0)
    08-16 20:35:03.012 20727-20727/br.com.ubook.ubooktim W/System.err: android.view.InflateException: Binary XML file line #135: Error inflating class Button
    08-16 20:35:03.022 20727-20727/br.com.ubook.ubooktim W/System.err:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
    08-16 20:35:03.032 20727-20727/br.com.ubook.ubooktim W/System.err:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
    08-16 20:35:03.042 20727-20727/br.com.ubook.ubooktim W/System.err:     at br.com.ubook.ubookapp.ui.fragment.BaseFragment.onCreateView(BaseFragment.java:59)
            at android.support.v4.app.Fragment.performCreateView(Fragment.java:2346)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1428)
            at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1759)
    
    opened by paulocoutinhox 9
  • Add a border_overlay attribute and allow drawing border on image

    Add a border_overlay attribute and allow drawing border on image

    Setting the border_inset attribute to false tells CircleImageView not to scale the image down to fit inside the border. This is useful to draw a translucent outline for subtle background protection without sacrificing any real estate.

    opened by Alexander-Prime 9
  • Edges getting cut if we use elevation.

    Edges getting cut if we use elevation.

    When we use elevation, The edges are getting cut.

    CircleImageView

    Code I'm using:

                <FrameLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center">
    
                    <de.hdodenhof.circleimageview.CircleImageView
                        android:id="@+id/profilePic"
                        android:layout_width="40dp"
                        android:layout_height="40dp"
                        android:layout_gravity="center"
                        android:layout_marginTop="2dp"
                        android:elevation="3dp"
                        android:src="@drawable/ic_user_profile" />
    
                    <ImageView
                        android:id="@+id/tick"
                        android:layout_width="16dp"
                        android:layout_height="16dp"
                        android:layout_gravity="end"
                        android:elevation="3dp"
                        android:outlineProvider="none"
                        android:src="@drawable/tick" />
                </FrameLayout>
    
    opened by nareshkatta99 8
  • The following classes could not be instantiated: - de.hdodenhof.circleimageview.CircleImageView

    The following classes could not be instantiated: - de.hdodenhof.circleimageview.CircleImageView

    used

    <de.hdodenhof.circleimageview.CircleImageView
                android:id="@+id/profile_image"
                android:layout_width="96dp"
                android:layout_height="96dp"
                android:src="@drawable/profile"
                app:civ_border_color="#FF000000"
                app:civ_border_width="2dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />
    

    from "usage" section in readme. Keep getting exeption:

    java.lang.NoClassDefFoundError: de/hdodenhof/circleimageview/R$styleable
    	at de.hdodenhof.circleimageview.CircleImageView.<init>(CircleImageView.java:100)
    	at de.hdodenhof.circleimageview.CircleImageView.<init>(CircleImageView.java:94)
    	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    	at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:351)
    	at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:200)
    	at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:161)
    	at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:294)
    	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:417)
    	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:428)
    	at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:332)
    	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
    	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1127)
    	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
    	at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101)
    	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
    	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1130)
    	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
    	at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101)
    	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
    	at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
    	at android.view.LayoutInflater.inflate(LayoutInflater.java:505)
    	at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:359)
    	at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:436)
    	at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:121)
    	at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:717)
    	at com.android.tools.idea.rendering.RenderTask.lambda$inflate$9(RenderTask.java:873)
    	at com.android.tools.idea.rendering.RenderExecutor$runAsyncActionWithTimeout$3.run(RenderExecutor.kt:192)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    	at java.base/java.lang.Thread.run(Thread.java:829)
    

    Piece of source file CircleImageView.java

    public CircleImageView(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
    
            TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView, defStyle, 0);
    
            mBorderWidth = a.getDimensionPixelSize(R.styleable.CircleImageView_civ_border_width, DEFAULT_BORDER_WIDTH);
            mBorderColor = a.getColor(R.styleable.CircleImageView_civ_border_color, DEFAULT_BORDER_COLOR);
            mBorderOverlay = a.getBoolean(R.styleable.CircleImageView_civ_border_overlay, DEFAULT_BORDER_OVERLAY);
            mCircleBackgroundColor = a.getColor(R.styleable.CircleImageView_civ_circle_background_color, DEFAULT_CIRCLE_BACKGROUND_COLOR);
    
            a.recycle();
    
            init();
        }
    

    Every "R." is causing an error "Connot resolve symbol R"

    Please, help. Maybe i'm using it wrongly?

    <?xml version="1.0" encoding="utf-8"?>
    <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".ui.fragments.SettingsFragment">
    
        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:background="@color/material_drawer_primary"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">
    
            <de.hdodenhof.circleimageview.CircleImageView
                android:id="@+id/profile_image"
                android:layout_width="96dp"
                android:layout_height="96dp"
                android:src="@drawable/profile"
                app:civ_border_color="#FF000000"
                app:civ_border_width="2dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />
        </androidx.constraintlayout.widget.ConstraintLayout>
    
    
    </androidx.constraintlayout.widget.ConstraintLayout>
    
    
    opened by tireks 0
  • CircleImageView OutOfMemoryError

    CircleImageView OutOfMemoryError

    Caused by java.lang.OutOfMemoryError Failed to allocate a 252016 byte allocation with 137008 free bytes and 133KB until OOM dalvik.system.VMRuntime.newNonMovableArray (VMRuntime.java)

    android.widget.ImageView. (ImageView.java:145) de.hdodenhof.circleimageview.CircleImageView. (CircleImageView.java:89) de.hdodenhof.circleimageview.CircleImageView. (CircleImageView.java:85)

    opened by billdizl 1
  • Width and height must be > 0 when using CircularProgressDrawable

    Width and height must be > 0 when using CircularProgressDrawable

    CircularProgressDrawable progress = new CircularProgressDrawable(context); progress.setColorSchemeColors(R.color.colorPrimary, R.color.colorPrimaryDark, R.color.colorAccent); progress.setCenterRadius(30f); progress.setStrokeWidth(5f); progress.start();

    Glide.with(context) .load(url) .dontAnimate() .error(R.color.color_secondary_10) .placeholder(progress) .into(view);

    Hi, when i use CircularProgressDrawable with Glide , I get the following error ,can someone help me? (Also, I did not encounter this problem in other image views.)

    W/System.err: java.lang.IllegalArgumentException: width and height must be > 0 W/System.err: at android.graphics.Bitmap.createBitmap(Bitmap.java:1150) at android.graphics.Bitmap.createBitmap(Bitmap.java:1117) at android.graphics.Bitmap.createBitmap(Bitmap.java:1067) at android.graphics.Bitmap.createBitmap(Bitmap.java:1028) at de.hdodenhof.circleimageview.CircleImageView.getBitmapFromDrawable(CircleImageView.java:318) at de.hdodenhof.circleimageview.CircleImageView.initializeBitmap(CircleImageView.java:335) at de.hdodenhof.circleimageview.CircleImageView.setImageDrawable(CircleImageView.java:263) at com.bumptech.glide.request.target.ImageViewTarget.setDrawable(ImageViewTarget.java:53) at com.bumptech.glide.request.target.ImageViewTarget.onLoadStarted(ImageViewTarget.java:66) at com.bumptech.glide.request.SingleRequest.begin(SingleRequest.java:258)

    opened by egeysn 0
  • App crash in Android OS version 7(nougat),  Error inflating class de.hdodenhof.circleimageview.CircleImageView

    App crash in Android OS version 7(nougat), Error inflating class de.hdodenhof.circleimageview.CircleImageView

    Hello there,

    I used this library and it's working fine in android 8,9,10 & 11 but in android 7 app crashing,

    I used below code:=> <de.hdodenhof.circleimageview.CircleImageView android:id="@+id/ivProfile" android:layout_width="@dimen/_30sdp" android:layout_height="@dimen/_30sdp" android:src="@mipmap/ic_launcher_round" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" />

    please check below crash log:=>

    2021-09-06 16:54:19.094 4429-4429/com.app.voefa E/AndroidRuntime: FATAL EXCEPTION: main Process: com.app.voefa, PID: 4429 android.view.InflateException: Binary XML file line #28: Binary XML file line #28: Error inflating class de.hdodenhof.circleimageview.CircleImageView Caused by: android.view.InflateException: Binary XML file line #28: Error inflating class de.hdodenhof.circleimageview.CircleImageView Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:430) at android.view.LayoutInflater.createView(LayoutInflater.java:645) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) at android.view.LayoutInflater.rInflate(LayoutInflater.java:858) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) at android.view.LayoutInflater.rInflate(LayoutInflater.java:861) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) at android.view.LayoutInflater.inflate(LayoutInflater.java:518) at android.view.LayoutInflater.inflate(LayoutInflater.java:426) at androidx.databinding.DataBindingUtil.inflate(DataBindingUtil.java:126) at androidx.databinding.DataBindingUtil.inflate(DataBindingUtil.java:95) at com.app.voefa.ui.home.bottomMenu.FeedListAdapter.onCreateViewHolder(FeedListAdapter.java:40) at com.app.voefa.ui.home.bottomMenu.FeedListAdapter.onCreateViewHolder(FeedListAdapter.java:23) at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:7295) at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6416) at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6300) at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6296) at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2330) at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1631) at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1591) at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:668) at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4309) at androidx.recyclerview.widget.RecyclerView.onMeasure(RecyclerView.java:3686) at android.view.View.measure(View.java:19734) at androidx.constraintlayout.widget.ConstraintLayout$Measurer.measure(ConstraintLayout.java:792) at androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure.measure(BasicMeasure.java:480) at androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure.measureChildren(BasicMeasure.java:134) at androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure.solverMeasure(BasicMeasure.java:277) at androidx.constraintlayout.solver.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:119) at androidx.constraintlayout.widget.ConstraintLayout.resolveSystem(ConstraintLayout.java:1578) at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1690) at android.view.View.measure(View.java:19734) at androidx.core.widget.NestedScrollView.measureChildWithMargins(NestedScrollView.java:1599) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at androidx.core.widget.NestedScrollView.onMeasure(NestedScrollView.java:585) at android.view.View.measure(View.java:19734) at androidx.constraintlayout.widget.ConstraintLayout$Measurer.measure(ConstraintLayout.java:792) at androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure.measure(BasicMeasure.java:480) at androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure.measureChildren(BasicMeasure.java:134) at androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure.solverMeasure(BasicMeasure.java:277) 2021-09-06 16:54:19.095 4429-4429/com.app.voefa E/AndroidRuntime: at androidx.constraintlayout.solver.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:119)

    opened by Dhaval3344 2
Owner
Henning Dodenhof
Henning Dodenhof
This app brings Privacy dashboard features from Android 12 to older android devices.

PrivacyDashboard This app brings Privacy dashboard features from Android 12 to older android devices. Have you ever thought which apps are accessing y

Rushikesh Kamewar 234 Jan 7, 2023
Share food-Android- - Food donation coded in native android with firebase, google maps api and php server xampp

share_food-Android- Instructions: 1. Create a firebase account and link it with the project via google-services.json. 2. This project also uses a XAMP

Abubakar 3 Dec 28, 2021
Simple Android app during a coding night. Just Learning Firebase and Android

KUI-App Simple Android app during a coding night. Just Learning Firebase and Android What we learned: Some basics of Android Basic setup of Firebase:

Kibabii University Informatics Club (KUI) 7 Aug 28, 2022
A hybrid chat android application based on the features of Instagram and Whatsapp having UI just as Telegram.

GupShup About App It is a free online chat android application, enabling user to create a free user account and then log in using the credentials. Aft

Ratik Tiwari 1 May 22, 2022
Geoponics is an E-Commerce Android Based Application Designed for Farmers As Well As Normal Users to Buy and Sell Agricultural goods!

Geoponics : E-Commerce Application Geoponics is an E-Commerce Android Based Aplication Designed for Farmers As Well As Normal Users to Buy and Sell Ag

Prasad 3 Aug 31, 2021
Dual Camera, IMU, and GPS data recorder for Android

Visual-Inertial Recorder (VIRec) Record camera frames at ~30fps from one or two camera sensors, Inertial Measurement Unit (IMU) measurements at ~100Hz

AUT 3D Vision 17 Oct 24, 2022
A complete and performing library to highlight text snippets (EditText, SpannableString and TextView) using Spannable with Regular Expressions (Regex) for Android.

Highlight A complete and performing library to highlight text snippets (EditText/Editable and TextView) using Spannable with Regular Expressions (Rege

Irineu A. Silva 16 Dec 22, 2022
Experimental Discord Mobile Rich Presence (Android)

MRPC Experimental Discord Mobile Rich Presence (Android) How does it work? It's pretty simple. Connect to the Discord Gateway as a normal Discord Clie

Duy Tran Khanh 41 Dec 25, 2022
A simple and scalable Android bot emulation framework, as presented at Black Hat Europe 2021's Arsenal, as well as atHack 2021's Arsenal

m3 A simple and scalable Android bot emulation framework. A detailed explanation can be found here. This project was first published at Black Hat Euro

null 22 Aug 20, 2022
trace all binder-funcion calls on android-platform

BinderHackDemo trace all binder-funcion calls on android-platform 该demo展示了如何使用libbinderhack.so模块,trace-app自身进程binder调用情况 您可以通过该次提交,查看如何使用libbinderhack

null 4 Dec 25, 2021
All the Android-Java Projects in Single Repository

Android Java Projects List of Projects Factorial Calculator Multiplication Table Web App Steps to Run the Applications Clone this Repository Create a

Rajan Gautam 2 Oct 10, 2022
Image Cropping Library for Android

uCrop - Image Cropping Library for Android This project aims to provide an ultimate and flexible image cropping experience. Made in Yalantis How We Cr

Yalantis 11.4k Jan 2, 2023
Fast Android Development. Easy maintainance.

Fast Android Development. Easy maintenance. AndroidAnnotations is an Open Source framework that speeds up Android development. It takes care of the pl

null 11.1k Dec 31, 2022
Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more.

Stetho Stetho is a sophisticated debug bridge for Android applications. When enabled, developers have access to the Chrome Developer Tools feature nat

Meta 12.6k Jan 3, 2023
A tool for reverse engineering Android apk files

Apktool This is the repository for Apktool. If you are looking for the Apktool website. Click here. It is a tool for reverse engineering 3rd party, cl

Connor Tumbleson 15.4k Jan 4, 2023
Modular and customizable Material Design UI components for Android

Material Components for Android Material Components for Android (MDC-Android) help developers execute Material Design. Developed by a core team of eng

Material Components 14.4k Jan 3, 2023
A libre lightweight streaming front-end for Android.

NewPipe A libre lightweight streaming frontend for Android. Screenshots • Description • Features • Installation and updates • Contribution • Donate •

Team NewPipe 22.4k Jan 3, 2023
Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.

Tinker Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstalling apk. Getting started Add t

Tencent 16.6k Dec 30, 2022
An Android library for managing images and the memory they use.

Fresco Fresco is a powerful system for displaying images in Android applications. Fresco takes care of image loading and display, so you don't have to

Meta 16.9k Jan 3, 2023