A Light-weight Popping Animation Android Library!
Straightforward to make use of Small Measurement 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 format 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(
measurement = 100F,
drawable = ContextCompat.getDrawable(context, R.drawable.popcorn)!!,
)
popcornView.begin(
form = form,
quantity = 40,
interval = 10,
)
gravity: The acceleration resulting from 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:
measurement = 100F,
textual content = “Pop!”,
textColor = ContextCompat.getColor(this, R.colour.yellow)
)
measurement (required): The dimensions of the textual content to be drawn. textual content (required): The textual content to be drawn. textColor (non-obligatory): The colour of the textual content to be drawn. (Default: Coloration.BLACK).
DrawableShape
measurement = 100F,
drawable = ContextCompat.getDrawable(this, R.drawable.popcorn)!!,
)
DrawableShape represents a form that’s drawn as a drawable. It has the next properties:
measurement (required): The dimensions of the drawable to be drawn. drawable (required): The drawable to be drawn.
Setting place to pop
You’ll be able to specify the place the place the popcorn will probably be generated from within the begin() methodology.
PopcornView.begin(…startX: Float, startY): Generates popcorn from the coordinates (startX, startY).
Alternatively, you should utilize 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’re welcome to contribute to this venture. For those who discover any bugs, have any characteristic requests or ideas, or simply wish to enhance the code, be at liberty to open a problem or submit a pull request. Your contributions are drastically appreciated.
License
This venture is licensed underneath the phrases of the MIT license. See LICENSE for extra info.