Last active
February 26, 2020 17:16
-
-
Save AmaroNeto/55a336dc617a9ad3baf9bec06eff8612 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.android.animationproject.view | |
import android.animation.AnimatorSet | |
import android.os.Bundle | |
import android.view.View | |
import android.view.ViewTreeObserver.OnGlobalLayoutListener | |
import androidx.appcompat.app.AppCompatActivity | |
import androidx.cardview.widget.CardView | |
import androidx.constraintlayout.widget.ConstraintLayout | |
import androidx.core.content.ContextCompat | |
import com.android.animationproject.R | |
import com.android.animationproject.utils.AnimatorUtils | |
class ExpandViewActivity : AppCompatActivity() { | |
private lateinit var cardBox: CardView | |
private lateinit var intro: ConstraintLayout | |
private lateinit var detail: ConstraintLayout | |
private var shouldExpand = true | |
private var oldHeight = 0 | |
private var newHeight= 0 | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_expand_view) | |
cardBox = findViewById(R.id.card_container) | |
intro = findViewById(R.id.intro) | |
detail = findViewById(R.id.detail) | |
setViewHeight() | |
cardBox.setOnClickListener { | |
if(shouldExpand) { | |
expandAnimation() | |
shouldExpand = shouldExpand.not() | |
} else { | |
collapseAnimation() | |
shouldExpand = shouldExpand.not() | |
} | |
} | |
} | |
private fun setViewHeight() {...} | |
private fun expandAnimation() {...} | |
private fun collapseAnimation() {...) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment