Skip to content

Instantly share code, notes, and snippets.

Avatar
💪
Hustling

Damanpreet Singh damanpreetsb

💪
Hustling
View GitHub Profile
@damanpreetsb
damanpreetsb / MainActivity.java
Created Dec 8, 2016
Viewpager by using ArrayList
View MainActivity.java
package com.example.daman.swipefragmentdemo;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
View RotateBoxAnimatorSet.kt
AnimatorSet().apply { play(scaleDownX).with(scaleDownY).with(rotateBox).before(translateX) }
View RotateBoxTranslateXAnimation.kt
val translateX = ObjectAnimator.ofFloat(backCoverImageView, "translationX", 0f, 1000f)
View RotateBoxAnimation.kt
val rotateBox = ObjectAnimator.ofFloat(backCoverImageView, "rotation", 0f, -45f)
View RotateBoxScaleDownYAnimation.kt
val scaleDownY = ObjectAnimator.ofFloat(backCoverImageView, "scaleY", 1f, 0.6f)
View RotateBoxScaleDownXAnimation.kt
val scaleDownX = ObjectAnimator.ofFloat(backCoverImageView, "scaleX", 1f, 0.6f)
View AnimateFrontCover.kt
frontCoverImageView
.animate()
.translationY(790f)
.setDuration(300)
.setListener(object : Animator.AnimatorListener {
override fun onAnimationEnd(animation: Animator?) {
backCoverImageView.visibility = VISIBLE
backCoverImageView.alpha = 1f
pizzaImageView.visibility = GONE
frontCoverImageView.visibility = GONE
View AnimateCheeseHeight.kt
val anim = ValueAnimator.ofInt(pizzaCheeseImageView.measuredHeight, height)
anim.addUpdateListener { valueAnimator ->
val value = valueAnimator.animatedValue as Int
val layoutParams = pizzaCheeseImageView.layoutParams
layoutParams.height = value
pizzaCheeseImageView.layoutParams = layoutParams
}
anim.duration = 300
anim.start()
View AnimateCrustHeight.kt
val anim = ValueAnimator.ofInt(pizzaCrustImageView.measuredHeight, height)
anim.addUpdateListener { valueAnimator ->
val value = valueAnimator.animatedValue as Int
val layoutParams = pizzaCrustImageView.layoutParams
layoutParams.height = value
pizzaCrustImageView.layoutParams = layoutParams
pizzaCrustImageView.radius = value.div(2).toFloat()
}
anim.duration = 300
anim.start()
View AnimateToppings.kt
ObjectAnimator.ofFloat(toppingsLayout,"translationY", 0f, toppingsLayout.height.toFloat() - 12f).apply {
interpolator = AccelerateInterpolator()
duration = 600
start()
}