Milad Ge
Milad Ge

Reputation: 160

Custom ImageView With a Custom Shape

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

Upvotes: 2

Views: 4246

Answers (2)

Milad Ge
Milad Ge

Reputation: 160

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

Upvotes: 2

Pushpendra
Pushpendra

Reputation: 2819

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.

Upvotes: 0

Related Questions