Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customize the appearance of a <Key>

Some 3rd party keyboards have more than one character on each key, for example Better Keyboard 8 has numbers and punctuation above the letters on each key:

Better Keyboard screen shot

Can this be done with the <Key> tag? If so I cannot figure out how. I would appreciate if anybody knows how.

Thanks in advance, Barry

like image 891
Barry Fruitman Avatar asked May 14 '11 07:05

Barry Fruitman


People also ask

Can you customize keyboard iPhone?

You can use an alternative keyboard layout that doesn't match the keys on your keyboard. Go to Settings > General > Keyboard > Keyboards. Tap a language at the top of the screen, then select an alternative layout from the list.

What is slow key iPhone?

'Slow Keys' enable you to alter the amount of time the computer waits, when you hold a key down, before it accepts it. This is means that you can press many keys by accident and the device will ignore it until a key is held down for a specific length of time. To turn on 'Slow Keys': Tap on 'Slow Keys'.

Why won't my keyboard pop up on my iPad?

As is often the case with computers, it's possible that some sort of temporary software glitch is keeping the keyboard from appearing on screen. Restarting your iPad — turning it off and then back on again — can resolve most of these kinds of problems. Restart it and check the onscreen keyboard again.


1 Answers

I figured it out so I am answering my own question.

It cannot be done in XML, but it can be done in Java by overriding the onDraw() method of KeyboardView. This pointless example draws a small letter at the top of each key after the keys are drawn by the parent class:

public class MyKeyboardView extends KeyboardView {
    @Override
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        Paint paint = new Paint();
        paint.setTextAlign(Paint.Align.CENTER);
        paint.setTextSize(25);
        paint.setColor(Color.RED);

        List<Key> keys = getKeyboard().getKeys();
        for(Key key: keys) {
            if(key.label != null)
                canvas.drawText(key.label.toString(), key.x + (key.width/2), key.y + 25, paint);
        }
    }
}
like image 187
Barry Fruitman Avatar answered Oct 12 '22 06:10

Barry Fruitman