Search code examples
androidfresco

How to add custom Icon on fresco's rounded border in android


I am using Fresco image loader library and I want to add custom image icon on Fresco's rounded border only. I have googled to find such functionality but not got any proper solution. Kindly help me that how can it possible. I am attaching screenshot and I need such functionality as per my requirement. enter image description here


Solution

  • Fresco supports overlays, so just add an overlay to the drawee hierarchy with your icon.

    http://frescolib.org/docs/drawee-branches.html#Overlays

    For example, in XML you can do something like this:

    <com.facebook.drawee.view.SimpleDraweeView
      xmlns:fresco="http://schemas.android.com/apk/res-auto"
      android:id="@+id/my_image_view"
      android:layout_width="40dp"
      android:layout_height="40dp"
      fresco:overlayImage="@drawable/your_overlay"
      />
    

    You have to position the overlay image accordingly, for example by using a <bitmap android:gravity="bottom|right" />, ninepatch, or custom drawable. See also https://developer.android.com/guide/topics/resources/drawable-resource.html and How to get gravity 'bottom' working on a drawable in xml