Hide and show keyboard with insets controller
This commit is contained in:
1 parent
d8264ad0d7
commit
d48919a5c3
5 files changed
+46
-22
No files matched your search
@@ -56,14 +56,22 @@ public class WindowInsetsAnimationHelper extends WindowInsetsAnimationCompat.Cal
|
||||
if (animation == null) {
|
||||
return insets;
|
||||
}
|
||||
for (View view : views) {
|
||||
if (view == null) {
|
||||
continue;
|
||||
WindowInsetsAnimationCompat imeAnimation = null;
|
||||
for (WindowInsetsAnimationCompat animation : runningAnimations) {
|
||||
if ((animation.getTypeMask() & WindowInsetsCompat.Type.ime()) != 0) {
|
||||
imeAnimation = animation;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (imeAnimation != null) {
|
||||
for (View view : views) {
|
||||
if (view == null) {
|
||||
continue;
|
||||
}
|
||||
int startPadding = startPaddings.containsKey(view) ? startPaddings.get(view) : 0;
|
||||
int endPadding = endPaddings.containsKey(view) ? endPaddings.get(view) : 0;
|
||||
view.setTranslationY(MathUtils.lerp(endPadding - startPadding, 0, animation.getInterpolatedFraction()));
|
||||
}
|
||||
int startPadding = startPaddings.containsKey(view) ? startPaddings.get(view) : 0;
|
||||
int endPadding = endPaddings.containsKey(view) ? endPaddings.get(view) : 0;
|
||||
int offset = MathUtils.lerp(-(startPadding - endPadding), 0, animation.getInterpolatedFraction());
|
||||
view.setTranslationY(offset);
|
||||
}
|
||||
return insets;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user