Skip to content

gulzar1996/whatsapp-readby-animation

Repository files navigation

WhatsApp Readby Animation

Implemeting WhatsApp readby animation using ConstraintLayout. anim_none

Why ?

Animations in android can be difficult and can lead to writing many lines of code( Different code for exit/enter anim). With the help of Android's new ConstraintLayout one can create complex animations by writing few lines of code.

How ???

  • Creating duplicate xml files which contains the start and end postion of the animtions respectively.
readby_collapsed.xml start anim_none
readby_expanded.xml  end    anim_none
  • Creating constraint Set for both the layout
val constraintSet1 = ConstraintSet()
val constraintSet2 = ConstraintSet()
constraintSet1.clone(constraintLayout)
constraintSet2.clone(this,R.layout.readby_expanded)
  • Adding a TransitionManager to view the animation
var changed = false
//Touch Listener
findViewById<View>(R.id.touch).setOnClickListener({
   TransitionManager.beginDelayedTransition(constraintLayout)
   val constraint = if (changed) constraintSet1 else constraintSet2
   constraint.applyTo(constraintLayout)
   changed = !changed
  })
  • Voilà here's your beautiful animation.

About

WhatsApp readby animation using Constraint Layout

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages