android-shape-imageview

repository·master·Indexed 25 days ago

https://github.com/siyamed/android-shape-imageview

An 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.

Tokens
1.2K
Snippets
7
Records
9
Agent score
33%

What's inside android-shape-imageview

  1. Configure Proguard for android-shape-imageview

    master

    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.**{ *; }
  2. Parse SVG path strings into Android Path objects

    master

    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 path
    • L/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.

  3. Use PorterShapeImageView for Bitmap Masking

    master

    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=
  4. Configure CircularImageView

    master

    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=
  5. Configure BubbleImageView

    master

    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=
  6. Configure ShapeImageView and its subclasses

    master

    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=
  7. Configure RoundedImageView

    master

    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=