Skip to content

Instantly share code, notes, and snippets.

@AshuTyagi16
Created November 16, 2020 09:22
Show Gist options
  • Save AshuTyagi16/4f9c7c2cd4caf9a05496e02772fc41a8 to your computer and use it in GitHub Desktop.
Save AshuTyagi16/4f9c7c2cd4caf9a05496e02772fc41a8 to your computer and use it in GitHub Desktop.
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