Skip to content

DeveloperPaul123/StarView

Repository files navigation

StarView

🌟 Simple custom view that draws an n-point star for Android.

Say Thanks Discord Jitpack android-arsenal

Features

  • Draw any n-point star
  • Configurable colors
    • Supports background color, outline color and fill color
  • Supports curved corners with controllable corner radius
  • Control fill amount and direction

Include in your project

Gradle

Add the following to your root build.gradle:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Then add the dependency to your module's build.gradle file:

dependencies {
    implementation 'com.github.DeveloperPaul123:StarView:<version>'
}

Usage

Add the StarView to your layout xml:

<com.developerpaul123.starview.StarView
            android:id="@+id/starView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:minHeight="350dp"
            app:fillPercentage="0.5"
            app:outlineThickness="4.0" />

Other available attributes:

Attribute Value Type(s) Description
fillDirection StarView.FillDirection Control what direction the star is filled from.
fillPercentage float, clamped to 0.0 -> 1.0 Control the fill percentage.
numberOfPoints int, minimum of 3 Control the number of points in the star.
outlineThickness float Control the outline thickness.
starColor Color The fill color of the star.
starOutlineColor Color The outline color of the star.
starBackgroundColor Color The background color of the star. Only visible when not filled.
starCornerRadius float The corner radius for the points of the star.

All of the above attributes can be controlled via XML and Kotlin. See the demo application for more options and how they affect the view.

Contributing

Contributions are very welcome. Please see contribution guidelines for more info.

License

The project is licensed under the MIT license. See LICENSE for more details.

Author


@DeveloperPaul123