How to draw heart shaped ImageView in Android using PorterDuffXfermode and SVG


A library for supporting custom shaped ImageView(s) using SVGs and paint shapes

Play Store Demo: https://play.google.com/store/apps/details?id=com.meg7.samples

Library: https://github.com/MostafaGazar/CustomShapeImageView

This gist could also be used: https://gist.github.com/MostafaGazar/ee345987fa6c8924d61b if you do not want to add this library project to your codebase.

Usage:

<com.meg7.widget.SvgImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:src="@drawable/sample"
app:svg_raw_resource="@raw/shape_heart"
android:scaleType="centerCrop" />

Download:

dependencies {
...
compile 'com.mostafagazar:customshapeimageview:1.0.4'
...
}