RxAnimation

Additional

Language
Kotlin
Version
N/A
Created
Jun 18, 2019
Updated
Jul 5, 2019
Owner
Lopez Mikhael (lopspower)
Contributor
Lopez Mikhael (lopspower)
1
Activity
Badge
Generate
Download
Source code

Promotion

RxAnimation



This is an Android library to make a simple way to animate your views on Android with Rx.

USAGE

Add RxAnimation library via Gradle:

implementation 'com.mikhaellopez:rxanimation:0.0.4'

KOTLIN

  • Animate your views and handle it in Completable. For example alpha() and resize():
view1.alpha(1f)
    .andThen(view2.resize(100, 100))



  • If you want to apply animation one by one you can used RxAnimation.sequentially() instead of multi andThen():
RxAnimation.sequentially(
    view1.fadeIn(),
    view1.translation(20f, 30f),
    view2.backgroundColor(
        ContextCompat.getColor(this, R.color.accent),
        ContextCompat.getColor(this, R.color.primary)
    ),
    view2.resize(100, 100)
)

  • You can also used RxAnimation.from(view) if you want to update multi properties one by one in the same view:
RxAnimation.from(view)
    .fadeIn()
    .translation(20f, 30f)
    .backgroundColor(
        ContextCompat.getColor(this, R.color.accent),
        ContextCompat.getColor(this, R.color.primary)
    )
    .resize(100, 100)

  • You can also use the range() function to animate a change on a custom property:
(4f, 20f).rangeFloatToCompletable { 
    circularImageView.borderWidth = it 
}

// or

RxAnimation.from(circularImageView)
    .rangeFloat(4f, 20f) { circularImageView.borderWidth = it }

ALL PROPERTIES

Default

Properties View to Completable RxAnimation.from(view)
alpha alpha alpha
translationX translationX translationX
translationY translationY translationY
translation X + Y translation(X, Y) translation(X, Y)
scaleX scaleX scaleX
scaleY scaleY scaleY
scale X = Y scale scale
rotation rotation rotation
rotationX rotationX rotationX
rotationY rotationY rotationY
X x x
Y y y
Z z z
X + Y + Z xyz xyz
backgroundColor backgroundColor backgroundColor
width width width
height height height
width + height resize resize
ValueAnimator start startValueAnimator
ViewPropertyAnimator animate -

Custom Properties

View to Completable RxAnimation.from(view)
rangeFloatToCompletable rangeFloat
rangeIntToCompletable rangeInt

Smart function

Animation View to Completable RxAnimation.from(view)
alpha=1f fadeIn fadeIn
alpha=0f fadeOut fadeOut
shake shake shake
press press press

ℹ️ All the functions have duration: Long, interpolator: TimeInterpolator & startDelay: Long properties.

LICENCE

RxAnimation by Lopez Mikhael is licensed under a Apache License 2.0.