Skip to content

Instantly share code, notes, and snippets.

@manwithsteelnerves
Last active December 12, 2019 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save manwithsteelnerves/f5084caab10733f2b26eae307c36f271 to your computer and use it in GitHub Desktop.
Save manwithsteelnerves/f5084caab10733f2b26eae307c36f271 to your computer and use it in GitHub Desktop.
webView.setOnTouchListener(new View.OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent event)
{
int actionEvent = event.getAction();
switch (actionEvent)
{
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_UP:
if (!v.hasFocus())
{
v.requestFocus();
}
if((actionEvent == MotionEvent.ACTION_UP))
{
Rect screenRect = getScreenSize();
if(event.getRawY() > (screenRect.height()/3))
{
adjustableScrollY = (int) (event.getRawY() - (screenRect.height() / 3));
}
else
{
adjustableScrollY = 0;
}
}
break;
}
return false;
}
});
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Call adjustKeyboard based on KeyboardHelper.java (Check Gist) notifications.
public void adjustKeyboard(boolean isVisible)
{
if(NativePluginHelper.isRunningInFullScreenMode())//Just checkes if FLAG_FULLSCREEN flag is set on Activity
{
if (rect.height() >= 0.9f && rect.top <= 0.1f) {
if (isVisible) {
animateViewProperty(webView, "translationY", -adjustableScrollY, 500);
} else {
animateViewProperty(webView, "translationY", 0f, 500);
adjustableScrollY = 0;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment