A Light-weight Popping Animation Android Library!
Simple to make use of Small Dimension Extremely Customizable
Getting Began
To make use of this library in your venture, add the next dependency to your construct.gradle file:
repositories {
…
maven { url ‘https://jitpack.io’ }
}
}
implementation ‘com.github.gold24park:PopcornView:release-1.0.2’
}
Utilization
Add the PopcornView to your structure XML file:
android:id=”@+id/popcornView”
android:layout_width=”match_parent”
android:layout_height=”match_parent”
app:popcornAmount=”30″ />
Or, configure the popcorn properties and begin the animation programmatically:
val form = PopcornShape.DrawableShape(
dimension = 100F,
drawable = ContextCompat.getDrawable(context, R.drawable.popcorn)!!,
)
popcornView.begin(
form = form,
quantity = 40,
interval = 10,
)
gravity: The acceleration because of gravity in pixels per second squared. (Default: 0.37F) minVelocity: The minimal velocity of the popcorn in pixels per second. (Default: 20) maxVelocity: The utmost velocity of the popcorn in pixels per second. (Default: 40) angleRangeStart: The minimal launch angle of the popcorn in levels. (Default: 45) angleRangeEnd: The utmost launch angle of the popcorn in levels. (Default: 135) elasticity: The elasticity of the collisions between the popcorn and the partitions. (Default: 0.6F) friction: The friction coefficient of the popcorn on the partitions. (Default: 0.39F) ttl: The time-to-live of the popcorn in milliseconds. (Default: 30,000L) fadeout: Whether or not the popcorn ought to fade out earlier than disappearing. (Default: true)
Customise Shapes with PopcornShape
TextShape
TextShape represents a form that’s drawn as textual content. It has the next properties:
dimension = 100F,
textual content = “Pop!”,
textColor = ContextCompat.getColor(this, R.shade.yellow)
)
dimension (required): The dimensions of the textual content to be drawn. textual content (required): The textual content to be drawn. textColor (elective): The colour of the textual content to be drawn. (Default: Coloration.BLACK).
DrawableShape
dimension = 100F,
drawable = ContextCompat.getDrawable(this, R.drawable.popcorn)!!,
)
DrawableShape represents a form that’s drawn as a drawable. It has the next properties:
dimension (required): The dimensions of the drawable to be drawn. drawable (required): The drawable to be drawn.
Setting place to pop
You possibly can specify the place the place the popcorn shall be generated from within the begin() technique.
PopcornView.begin(…startX: Float, startY): Generates popcorn from the coordinates (startX, startY).
Alternatively, you should use the StartPosition:
StartPosition
xAxis: XAxisPosition.CENTER,
yAxis: YAxisPosition.CENTER,
)
xAxis: XAxisPosition.LEFT | XAxisPosition.CENTER | XAxisPosition.RIGHT yAxis: YAxisPosition.TOP | YAxisPosition.CENTER | YAxisPosition.BOTTOM
Contribute
You might be welcome to contribute to this venture. Should you discover any bugs, have any function requests or recommendations, or simply wish to enhance the code, be happy to open a problem or submit a pull request. Your contributions are enormously appreciated.
License
This venture is licensed below the phrases of the MIT license. See LICENSE for extra data.