4

I am developing a soft-keyboard for android with the goal of expanding the original 8pen keyboard in mind which is now discontinued.
I have the basic structure working and now want to make the size of the keyboard user-configurable.

Is there a way to configure the height and width of the keyboard?
Since a few people have asked what my code looks like following is a snippet and the full up to date version can be found here -> 8Vim

    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    /*Logging stuff*/
    int width = View.MeasureSpec.getSize(widthMeasureSpec);
    int height = View.MeasureSpec.getSize(heightMeasureSpec);
    /*Various other Stuff*/
    radius = (0.325f * width) / 2;
    centre = new PointF((width/2),(height/2));
    circle = new Circle(centre, radius);
    // Set the new size because the "onMeasure" contract so specifies
    setMeasuredDimension(width, height);
    Logger.v(this, "onMeasure returns");
}

UPDATE:

So I have found that the InputServiceMethod class has a method called getMaxWidth(), and if I set my keyboard's width less then this in my view class (responsible for displaying the keyboard), the remaining area on the right side of the keyboard blacks out and no longer usable.

I get the Idea that if I change the height of the keyboard in the view class itself, I might be able to achieve what I am looking for, but... is it possible to change the height of the view on user's whim? Any advise/Ideas/Experience is welcome.

flide
  • 189
  • 16

2 Answers2

0

Here you go, use the code, it's just what you want

mRootWindow = getWindow();
mRootView = mRootWindow.getDecorView().findViewById(android.R.id.content);
mRootView.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout(){
    Rect r = new Rect();
    View view = mRootWindow.getDecorView();
    view.getWindowVisibleDisplayFrame(r);
    // r.left, r.top, r.right, r.bottom
}
});
johnrao07
  • 6,690
  • 4
  • 32
  • 55
  • 1
    So effectively, I need to configure the "Rect r" and it will be show up? As far as I read, do I not need to mess with the "onMeasure" function in my view? – flide Nov 23 '15 at 08:16
  • well , you haven't posted your code. And this stuff worked for a friend – johnrao07 Nov 23 '15 at 08:19
  • Updated the question, and added code... not sure if that is going to help at all.. – flide Nov 23 '15 at 09:47
0

if i am not mistaken you want to know the soft keyboard of android phone's height and width then follow this link, might help you. Is there any way in android to get the height of virtual keyboard of device

Community
  • 1
  • 1
  • The link you have mentioned is for application to detect if the soft-keyboard is open, and at best I can get is the current size of the keyboard, but it does not say how to set it... My application IS a keyboard, and want to change the height and width of the keyboard dynamically. – flide Nov 23 '15 at 08:23