Use Shader-Based ImageViews for smooth scrolling
masterPath class. These are highly performant and are recommended for use within recycling views like ListView or GridView to ensure smooth scrolling.repository·master·Indexed 25 days ago
https://github.com/siyamed/android-shape-imageviewAn Android library for custom shaped ImageView components using shader-based and bitmap mask-based techniques. It provides specialized views including CircularImageView, RoundedImageView, BubbleImageView, and ShapeImageView (supporting Diamond, Pentagon, Hexagon, Octogon, Star, and Heart shapes), as well as PorterShapeImageView for bitmap masking. Includes a PathParser to convert SVG path data strings into android.graphics.Path objects.
Path class. These are highly performant and are recommended for use within recycling views like ListView or GridView to ensure smooth scrolling.Add the following dependency to your build.gradle file to use the library. Note the use of the @aar suffix for the dependency.
compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'Add the following rules to your Proguard configuration to prevent issues with Android support libraries and to ensure the library classes are preserved.
-dontwarn android.support.v7.**
-keep class android.support.v7.** { ; }
-keep interface android.support.v7.* { ; }
-keepattributes *Annotation,Signature
-dontwarn com.github.siyamed.**
-keep class com.github.siyamed.shapeimageview.**{ *; }Use PathParser.doPath(String s) to convert an SVG path data string (the d attribute from an SVG <path> element) into a usable android.graphics.Path object.
Supported SVG path commands include:
M/m: Move to (absolute/relative)Z/z: Close pathL/l: Line to (absolute/relative)H/h: Horizontal line to (absolute/relative)V/v: Vertical line to (absolute/relative)C/c: Cubic bezier to (absolute/relative)S/s: Smooth cubic bezier to (absolute/relative)Q/q: Quadratic bezier to (absolute/relative)T/t: Smooth quadratic bezier to (absolute/relative)A/a: Elliptical arc (absolute/relative)Uppercase commands represent absolute positions, while lowercase commands represent relative positions.
The PorterShapeImageView uses xfermode to combine a source image with a mask. This is useful for very custom shapes but is not recommended for recycling views because it requires extra bitmaps.
Attributes:
siShape: The mask shape, which can be a drawable (like an Android shape XML) or a bitmap.siSquare: If true, sets both width and height to the minimum of the provided values.```XML
<com.github.siyamed.shapeimageview.mask.PorterShapeImageView
android:layout_width=Use CircularImageView for circular images.
Attributes:
siBorderColor: Color of the border.siBorderWidth: Border width in dp.siBorderAlpha: Alpha value of the border (0.0 to 1.0).```XML
<com.github.siyamed.shapeimageview.CircularImageView
android:layout_width=Use BubbleImageView to create chat-bubble shaped images.
Attributes:
siTriangleHeight: Height of the bubble pointer in dp.siArrowPosition: Direction of the arrow (left or right).siSquare: If true, sets both width and height to the minimum of the provided values.```XML
<com.github.siyamed.shapeimageview.BubbleImageView
android:layout_width=The ShapeImageView class (and its subclasses like DiamondImageView, PentagonImageView, HexagonImageView, OctogonImageView, StarImageView, and HeartImageView) can process SVG files to build a Path object for drawing.
Supported SVG elements: rectangle, circle, ellipse, polygon, path, group, and their transformations.
Attributes:
siBorderColor: Color of the border.siBorderWidth: Border width in dp.siBorderAlpha: Alpha value of the border (0.0 to 1.0).siStrokeCap: Border stroke cap type (butt|round|square).siStrokeJoin: Border stroke join type (bevel|miter|round).siSquare: If true, sets both width and height to the minimum of the provided values.siShape: A reference to an SVG resource (used by ShapeImageView, not its subclasses).```XML
<com.github.siyamed.shapeimageview.{ClassName}
android:layout_width=Use RoundedImageView for rounded rectangle shapes with borders.
Attributes:
siBorderColor: Color of the border.siBorderWidth: Border width in dp.siBorderAlpha: Alpha value of the border (0.0 to 1.0).siRadius: Corner radius in dp.siSquare: If true, sets both width and height to the minimum of the provided values.```XML
<com.github.siyamed.shapeimageview.RoundedImageView
android:layout_width=