2

I am trying to create a custom ImageView that Shows images inside a custom border and shape instead of default rectangle, and out Side of The Borders are TransParent.

my border is an SVG File, How I can do this? thanks

Photo examples

Niraj
  • 903
  • 8
  • 23
Milad Ge
  • 160
  • 1
  • 9
  • see the sources of [RoundedBitmapDrawable](https://github.com/android-ia/platform_frameworks_support/blob/master/v4/donut/android/support/v4/graphics/drawable/RoundedBitmapDrawable.java) and create similar custom `Drawable` – pskink Dec 27 '16 at 10:44

2 Answers2

2

Use this library siyamed/android-shape-imageview or create a custom view that extend from View class and override methods!

But the easiest way is using this library

create a bitmap that you want to mask your original picture and use this like below :

 <com.github.siyamed.shapeimageview.mask.PorterShapeImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:layout_margin="8dp"
                app:siShape="@drawable/octogon" <!--mask bitmap-->
                android:src="@drawable/neo" <!-- original bitmap -->
app:siSquare="true"/>

screenShot

appersiano
  • 2,670
  • 22
  • 42
Milad Ge
  • 160
  • 1
  • 9
0

Extend the Image View class and change it according to your use. Not just Image View you can customized any view class you just need to extend parent class.

Pushpendra
  • 2,791
  • 4
  • 26
  • 49