Provides a set of custom shaped android imageview components, and a framework to define more shapes. Implements both shader and bitmap mask based image views.
- Shader based one uses canvas draw methods and Path construct,
- Mask based one uses xfermode to draw image on bitmaps defined by android shape XML's or resource bitmaps.
There are many projects online implementing such components, however one goal of this project is to provide a performant/smooth scrolling view component framework to define different shapes for imageviews.
For use with recycling view such as ListView or GridView please use shader based implementations.
Gradle dependency:
compile 'com.github.siyamed:android-shape-imageview:0.9@aar'
<com.github.siyamed.shapeimageview.BubbleImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/neo"
app:arrowPosition="right"
app:square="true"/>
Attributes:
triangleHeight
the height of the bubble pointer in dparrowPosition
where to point the arrow, currentlyleft|right
square
set width and height to the minimum of the given valuestrue|false
<com.github.siyamed.shapeimageview.RoundedImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/neo"
app:radius="6dp"
app:borderWidth="6dp"
app:borderColor="@color/darkgray"
app:square="true"/>
Attributes:
borderColor
border colorborderWidth
border width in dpborderAlpha
alpha value of the border between 0.0-1.0square
set width and height to the minimum of the given valuestrue|false
<com.github.siyamed.shapeimageview.CircularImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/neo"
app:borderWidth="6dp"
app:borderColor="@color/darkgray"/>
Attributes:
borderColor
border colorborderWidth
border width in dpborderAlpha
alpha value of the border between 0.0-1.0
####PorterShapeImageView
- With mask bitmap
<com.github.siyamed.shapeimageview.shape.PorterShapeImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:shape="@drawable/star"
android:src="@drawable/neo"
app:square="true"/>
- With shape XML
<com.github.siyamed.shapeimageview.shape.PorterShapeImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:shape="@drawable/shape_rounded_rectangle"
android:src="@drawable/neo"
app:square="true"/>
rounded rectangle shape definition in XML:
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:topLeftRadius="18dp"
android:topRightRadius="18dp"
android:bottomLeftRadius="18dp"
android:bottomRightRadius="18dp" />
<solid android:color="@color/black" />
</shape>
Attributes:
shape
the bitmap mask shape, either a shape drawable or a bitmapsquare
set width and height to the minimum of the given valuestrue|false
See/execute the sample for a demonstration of the components.
If you are lazy check this youtube video demonstrating scrolling in the sample app
- MostafaGazar/CustomShapeImageView: Used this project a basis for bitmap masks