I made an android custom keyboard
.
I want to use swiping on Space key
on the keyboard for changing keyboard layout to show next language layout.
How can i do that?
I used bellow class:
public class KeyboardIMS extends InputMethodService implements KeyboardView.OnKeyboardActionListener
{ ...}
You can do this by override touchEvent like this :
@Override
public boolean onTouchEvent(MotionEvent e) {
float x = e.getX();
float y = e.getY();
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN:
mIsDown = true;
break;
case MotionEvent.ACTION_MOVE:
float dx = x - mPreviousX;
float dy = y - mPreviousY;
// Here you can try to detect the swipe. It will be necessary to
// store more than the previous value to check that the user move constantly in the same direction
detectSwipe(dx, dy);
case MotionEvent.ACTION_UP:
mIsDown = false;
break;
}
mPreviousX = x;
mPreviousY = y;
return true;}