Created
June 7, 2019 10:14
-
-
Save damianpetla/2b7740b6dbb9cf7ed9df7da88f6f27b4 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
class AdItemHolder(item: View) : BaseHolder(item) { | |
private val adLabel = item.findViewById<View>(R.id.adlabel) | |
private val adContent = item.findViewById<View>(R.id.adcontent) | |
private val labelElevation = item.resources.getDimension(R.dimen.cardview_default_elevation) | |
init { | |
item.viewTreeObserver.addOnScrollChangedListener { | |
val offset = -item.top.toFloat() | |
adLabel.translationY = Math.max(offset, 0f) | |
adLabel.translationZ = if (offset < 0) labelElevation else 0f | |
adContent.translationY = offset | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment