Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cf6b3d1

Browse files
committed
Create magic animation kotlin class
1 parent 0348b5b commit cf6b3d1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package br.com.bloder.magic.internal
2+
3+
import android.view.View
4+
import android.view.animation.Animation
5+
import android.view.animation.Transformation
6+
7+
/**
8+
* Created by bloder on 20/09/16.
9+
*/
10+
class MagicAnimation(view : View) : Animation() {
11+
12+
private var view : View? = view
13+
private val startWidth : Int = view.width
14+
private val toWidth : Int = if (startWidth == view.height) startWidth * 4 else view.height
15+
16+
override fun applyTransformation(interpolatedTime: Float, t: Transformation?) {
17+
val newWidth : Int = startWidth + ((toWidth - startWidth) * interpolatedTime).toInt()
18+
view?.layoutParams?.width = newWidth
19+
view?.requestLayout()
20+
}
21+
}

0 commit comments

Comments
 (0)