Created
November 16, 2020 09:22
-
-
Save AshuTyagi16/4f9c7c2cd4caf9a05496e02772fc41a8 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
private fun getFloatRange(view: View): Float { | |
return 1f - (view.absY() / resources.displayMetrics.heightPixels.toFloat()) | |
} | |
//This function returns the y-cord of the view.. | |
fun View.absY(): Float { | |
val location = IntArray(2) | |
getLocationOnScreen(location) | |
return (location[1].toFloat() - height.toFloat()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment