Special Android keyboard with two slats (main and small in the upper right corner)

I use my own custom keyboard.

I use this tutorial to implement a keyboard

<?xml version="1.0" encoding="utf-8"?>

 <Row>
    <Key android:keyLabel="q" android:keyEdgeFlags="left"/>
    <Key android:keyLabel="w"/>
    <Key android:keyLabel="e"/>
    <Key android:keyLabel="r"/>
    <Key android:keyLabel="t"/>
    <Key android:keyLabel="y"/>
    <Key android:keyLabel="u"/>
    <Key android:keyLabel="i"/>
    <Key android:keyLabel="o"/>
    <Key android:keyLabel="p" android:keyEdgeFlags="right"/>
</Row>

I want to have 2 tags on the key button. Same as in the image below (red):

enter image description here

How can I change xml xml for this? When we make a long click on the button, we must choose numbers instead of letters

+2
source share
1 answer

you need to create the KeyboardView extends class and override the OnDraw method as follows:

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

        Paint paint = new Paint();
        paint.setTextSize(15);
        paint.setColor(Color.GRAY);

        List<Key> keys = getKeyboard().getKeys();
        for(Key key: keys) {
        if(key.codes[0] == 113)
            canvas.drawText("1", key.x + (key.width/2), key.y + 25, paint);
        }
    }
}

You can change the position by changing the x and y parameters.

enjoy :)

+4