Skip to content

Instantly share code, notes, and snippets.

@hiking93
Created April 21, 2022 09:59
Show Gist options
  • Save hiking93/7d9f5204a11e9a7a29c177f2a851e8dd to your computer and use it in GitHub Desktop.
Save hiking93/7d9f5204a11e9a7a29c177f2a851e8dd to your computer and use it in GitHub Desktop.
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { v, insets ->
val imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime())
Log.d("Hiking", "onApplyWindowInsets, bottom = ${imeInsets.bottom}")
insets
}
ViewCompat.setWindowInsetsAnimationCallback(
binding.root,
object : WindowInsetsAnimationCompat.Callback(DISPATCH_MODE_STOP) {
override fun onPrepare(animation: WindowInsetsAnimationCompat) {
super.onPrepare(animation)
Log.d("Hiking", "onPrepare")
}
override fun onStart(
animation: WindowInsetsAnimationCompat,
bounds: WindowInsetsAnimationCompat.BoundsCompat
): WindowInsetsAnimationCompat.BoundsCompat {
Log.d("Hiking", "onStart, bounds = $bounds")
return bounds
}
override fun onProgress(
insets: WindowInsetsCompat,
runningAnimations: MutableList<WindowInsetsAnimationCompat>,
): WindowInsetsCompat {
val imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime())
Log.d("Hiking", "onProgress, bottom = ${imeInsets.bottom}")
return insets
}
override fun onEnd(animation: WindowInsetsAnimationCompat) {
super.onEnd(animation)
Log.d("Hiking", "onEnd")
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment